First version of dashboard.
This commit is contained in:
parent
cf771d7f14
commit
1709208872
9 changed files with 249 additions and 7 deletions
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
|
||||
from collections import defaultdict
|
||||
import functools
|
||||
import inspect
|
||||
import re
|
||||
import six
|
||||
|
||||
from moto import settings
|
||||
from moto.packages.responses import responses
|
||||
|
|
@ -208,12 +210,38 @@ class Model(type):
|
|||
return dec
|
||||
|
||||
|
||||
model_data = defaultdict(dict)
|
||||
class InstanceTrackerMeta(type):
|
||||
def __new__(meta, name, bases, dct):
|
||||
cls = super(InstanceTrackerMeta, meta).__new__(meta, name, bases, dct)
|
||||
if name == 'BaseModel':
|
||||
return cls
|
||||
|
||||
service = cls.__module__.split(".")[1]
|
||||
if name not in model_data[service]:
|
||||
model_data[service][name] = cls
|
||||
cls.instances = []
|
||||
return cls
|
||||
|
||||
@six.add_metaclass(InstanceTrackerMeta)
|
||||
class BaseModel(object):
|
||||
def __new__(cls, *args, **kwargs):
|
||||
instance = super(BaseModel, cls).__new__(cls, *args, **kwargs)
|
||||
cls.instances.append(instance)
|
||||
return instance
|
||||
|
||||
|
||||
class BaseBackend(object):
|
||||
|
||||
def reset(self):
|
||||
self.__dict__ = {}
|
||||
self.__init__()
|
||||
|
||||
def get_models(self):
|
||||
import pdb;pdb.set_trace()
|
||||
models = getattr(backend.__class__, '__models__', {})
|
||||
|
||||
|
||||
@property
|
||||
def _url_module(self):
|
||||
backend_module = self.__class__.__module__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue