Beispiel #1
0
def test_load_lookup():

    class ObjectYAML(Model):
        __yaml__ = 'object'

    ModelRegistry.unregister(ObjectYAML)
    del ObjectYAML
Beispiel #2
0
def test_load_from_name():
    class ObjectFile(Model):
        # here is no __yaml__ attribute
        pass

    ModelRegistry.unregister(ObjectFile)
    del ObjectFile
Beispiel #3
0
def test_load_from_attribute_ext():

    class ObjectYAML(Model):
        __yaml__ = 'object.yaml'

    ModelRegistry.unregister(ObjectYAML)
    del ObjectYAML
Beispiel #4
0
    def add_model(self, model, *args, **kwargs):
        """ Register hopak model to admin views """
        from .views import ModelView
        if not isinstance(model, Model):
            if ModelRegistry.resolve(model._name, False):
                model = ModelRegistry.resolve(model._name, False)
            else:
                raise NotFoundModelException('Attempted to resolve model %s failed' % model)

        self.models.append(model)
        self.add_view(ModelView(model, *args, **kwargs))
Beispiel #5
0
 def index(self, models=[]):
     if not models:
         models = ModelRegistry.list()
     self.models = map(ModelRegistry.resolve, models)
     return self.render("form/root_view.html", models=self.models)