def register_domain(app, domain): """Add all resources in a domain to the app. The domain has to be deep-copied first because eve will modify it (since it heavily relies on setdefault()), which can cause problems especially in test environments, since the defaults don't get properly erase sometimes. TODO: Make tests better maybe so this is no problem anymore? Args: app (Eve object): The app to extend domain (dict): The domain to be added to the app, will not be changed """ domain_copy = deepcopy(domain) for resource, settings in domain_copy.items(): app.register_resource(resource, settings)
def __init__(self, app, endpoint_schema=None): if not endpoint_schema: endpoint_schema = {'schema': self.schema} if self.additional_lookup is not None: endpoint_schema.update({'additional_lookup': self.additional_lookup}) if self.extra_response_fields is not None: endpoint_schema.update({'extra_response_fields': self.extra_response_fields}) if self.datasource is not None: endpoint_schema.update({'datasource': self.datasource}) if self.item_methods is not None: endpoint_schema.update({'item_methods': self.item_methods}) if self.resource_methods is not None: endpoint_schema.update({'resource_methods': self.resource_methods}) if self.public_methods is not None: endpoint_schema.update({'public_methods': self.public_methods}) if self.url is not None: endpoint_schema.update({'url': self.url}) if self.item_url is not None: endpoint_schema.update({'item_url': self.item_url}) if self.embedded_fields is not None: endpoint_schema.update({'embedded_fields': self.embedded_fields}) if self.versioning is not None: endpoint_schema.update({'versioning': self.versioning}) if self.internal_resource is not None: endpoint_schema.update({'internal_resource': self.internal_resource}) if self.resource_title is not None: endpoint_schema.update({'resource_title': self.resource_title}) on_insert_event = getattr(app, 'on_insert_%s' % self.endpoint_name) on_insert_event += self.on_create on_inserted_event = getattr(app, 'on_inserted_%s' % self.endpoint_name) on_inserted_event += self.on_created on_update_event = getattr(app, 'on_update_%s' % self.endpoint_name) on_update_event += self.on_update on_updated_event = getattr(app, 'on_updated_%s' % self.endpoint_name) on_updated_event += self.on_updated on_delete_event = getattr(app, 'on_delete_item_%s' % self.endpoint_name) on_delete_event += self.on_delete on_deleted_event = getattr(app, 'on_deleted_item_%s' % self.endpoint_name) on_deleted_event += self.on_deleted app.register_resource(self.endpoint_name, endpoint_schema) superdesk.apps[self.endpoint_name] = self
def register_domain(app, domain): """Add all resources in a domain to the app. The domain has to be deep-copied first because eve will modify it (since it heavily relies on setdefault()), which can cause problems especially in test environments, since the defaults don't get properly erase sometimes. TODO: Make tests better maybe so this is no problem anymore? Args: app (Eve object): The app to extend domain (dict): The domain to be added to the app, will not be changed """ domain_copy = deepcopy(domain) for resource, settings in domain_copy.items(): # Add default for the resource title: # Capitalize like Eve does with item titles settings.setdefault('resource_title', resource.capitalize()) app.register_resource(resource, settings) _better_schema_defaults(app, resource, settings)
def _get_lock(): """Get mongolock instance using app mongodb.""" app.register_resource('_lock', _lock_resource_settings) # setup dummy resource for locks return SuperdeskMongoLock(client=app.data.mongo.pymongo('_lock').db)
def _get_lock(): """Get mongolock instance using app mongodb.""" app.register_resource('_lock', _lock_resource_settings) # setup dummy resource for locks return mongolock.MongoLock(client=app.data.mongo.pymongo('_lock').db)
def init_app(app): # this is required for mongo app.register_resource(TOKEN_RESOURCE, {'schema': AuthSubscriberTokenResource.schema})