def get_models(_, response, appname): """Return the models that comprise an application. """ root = get_slumber_root() app = get_application(appname) response['models'] = dict([(n, root + m.path) for n, m in app.models.items()])
def _configuration(config): """Process a configuratoin that is to be added to the service meta-data. """ from slumber.server.meta import IMPORTING assert IMPORTING, "Slumber itself must call configure" app = get_application(IMPORTING) app.configuration = config
def get_model(_, response, appname, modelname): """Return meta data about the model. """ app = get_application(appname) model = app.models[modelname] response['name'] = model.name response['module'] = model.app.name response['fields'] = model.fields # We have to access _meta # pylint: disable=W0212 response['puttable'] = [[f] for f in model.fields if model.model._meta.get_field(f).unique] + \ list(model.model._meta.unique_together) response['data_arrays'] = model.data_arrays response['operations'] = dict( [(op.name, get_slumber_root() + op.path) for op in model.operations() if op.model_operation])
def test_get_application(self): app = get_application('slumber_examples') self.assertEqual(app.name, 'slumber_examples') self.assertEqual(app.path, 'slumber_examples')
def test_get_application(self): app = get_application("slumber_examples") self.assertEqual(app.name, "slumber_examples") self.assertEqual(app.path, "slumber_examples")