def __init__(self, meta, **kwargs): SchemaOpts.__init__(self, meta, **kwargs) self.attrs_schema = getattr(meta, 'attrs_schema', None) self.aggs_schema = getattr(meta, 'aggs_schema', None) # self.errors_schema = getattr(meta, 'errors_schema', ResponseErrors) self.meta_schema = getattr(meta, 'meta_schema', TopLevelMeta) self.links_schema = getattr(meta, 'links_schema', TopLevelLinks) self.max_items_num = getattr(meta, 'max_items_num', 10000) if self.attrs_schema and not issubclass(self.attrs_schema, ObjectAttrs): raise Exception("{} must be a subclass of ObjectAttrs".format( self.attrs_schema)) if self.meta_schema and not issubclass(self.meta_schema, TopLevelMeta): raise Exception("{} must be a subclass of Meta".format( self.meta_schema)) if self.aggs_schema: if not issubclass(self.aggs_schema, schemas.ExtSchema): raise Exception("{} must be a subclass of ExtSchema".format( self.aggs_schema)) self.meta_schema.aggregations = fields.Nested(self.aggs_schema, many=False) if self.links_schema and not issubclass(self.links_schema, TopLevelLinks): raise Exception("{} must be a subclass of Links".format( self.links_schema))
def __init__(self, meta, **kwargs): SchemaOpts.__init__(self, meta, **kwargs) self.attrs_schema = getattr(meta, 'attrs_schema', None) if self.attrs_schema and not issubclass(self.attrs_schema, ObjectAttrs): raise Exception("{} must be a subclass of ObjectAttrs".format( self.attrs_schema))
def __init__(self, meta): BaseSchemaOpts.__init__(self, meta) # Use current app's config as defaults self.strict = getattr( meta, 'strict', current_app.config['MARSHMALLOW_STRICT'] ) self.dateformat = getattr( meta, 'dateformat', current_app.config['MARSHMALLOW_DATEFORMAT'] )
def __init__(self, meta): SchemaOpts.__init__(self, meta) # These marshmallow defaults are set explicitly so that the app context isn't required to access the config. # This allows us to reference Marshmallow classes at the module level, which is necessary for the documentation. self.strict = True self.dateformat = 'iso' self.context = getattr(meta, 'context', {}) if isinstance(self.context, threading.local): self.context = self.context.__dict__ self.views = getattr(meta, 'views', []) self.json_module = ju
def __init__(self, meta, **kwargs): SchemaOpts.__init__(self, meta, **kwargs) self.relationships_schema = getattr(meta, 'relationships_schema', None) if self.relationships_schema and not issubclass(self.relationships_schema, Relationships): raise Exception("{} must be a subclass of Relationships".format(self.relationships_schema)) self.meta_schema = getattr(meta, 'meta_schema', None) if self.meta_schema and not issubclass(self.meta_schema, ObjectAttrsMeta): raise Exception("{} must be a subclass of ObjectAttrsMeta".format(self.meta_schema)) self.object_type = getattr(meta, 'object_type', None) or 'undefined' self.model_name = getattr(meta, 'model', None) or None self.url_template = getattr(meta, 'url_template', None) or '{api_url}'
def __init__(self, meta, **kwargs): SchemaOpts.__init__(self, meta, **kwargs) self.model_name = getattr(meta, 'model', None)