How to use the marshmallow-sqlalchemy.schema.SchemaMeta function in marshmallow-sqlalchemy

To help you get started, we’ve selected a few marshmallow-sqlalchemy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raminfp / PYHelper / marshmallow-sqlalchemy / schema.py View on Github external
def get_declared_fields(mcs, klass, cls_fields, inherited_fields, dict_cls):
        """Updates declared fields with fields converted from the SQLAlchemy model
        passed as the `model` class Meta option.
        """
        declared_fields = dict_cls()
        opts = klass.opts
        Converter = opts.model_converter
        converter = Converter(schema_cls=klass)
        base_fields = super(SchemaMeta, mcs).get_declared_fields(
            klass, cls_fields, inherited_fields, dict_cls
        )
        declared_fields = mcs.get_fields(converter, opts, base_fields, dict_cls)
        declared_fields.update(base_fields)
        return declared_fields
github raminfp / PYHelper / marshmallow-sqlalchemy / schema.py View on Github external
class TableSchemaMeta(SchemaMeta):

    @classmethod
    def get_fields(mcs, converter, opts, base_fields, dict_cls):
        if opts.table is not None:
            return converter.fields_for_table(
                opts.table,
                fields=opts.fields,
                exclude=opts.exclude,
                include_fk=opts.include_fk,
                base_fields=base_fields,
                dict_cls=dict_cls,
            )
        return dict_cls()

class ModelSchemaMeta(SchemaMeta):

    @classmethod
    def get_fields(mcs, converter, opts, base_fields, dict_cls):
        if opts.model is not None:
            return converter.fields_for_model(
                opts.model,
                fields=opts.fields,
                exclude=opts.exclude,
                include_fk=opts.include_fk,
                base_fields=base_fields,
                dict_cls=dict_cls,
            )
        return dict_cls()

class TableSchema(with_metaclass(TableSchemaMeta, ma.Schema)):
github raminfp / PYHelper / marshmallow-sqlalchemy / schema.py View on Github external
declared_fields = dict_cls()
        opts = klass.opts
        Converter = opts.model_converter
        converter = Converter(schema_cls=klass)
        base_fields = super(SchemaMeta, mcs).get_declared_fields(
            klass, cls_fields, inherited_fields, dict_cls
        )
        declared_fields = mcs.get_fields(converter, opts, base_fields, dict_cls)
        declared_fields.update(base_fields)
        return declared_fields

    @classmethod
    def get_fields(mcs, converter, base_fields, opts):
        pass

class TableSchemaMeta(SchemaMeta):

    @classmethod
    def get_fields(mcs, converter, opts, base_fields, dict_cls):
        if opts.table is not None:
            return converter.fields_for_table(
                opts.table,
                fields=opts.fields,
                exclude=opts.exclude,
                include_fk=opts.include_fk,
                base_fields=base_fields,
                dict_cls=dict_cls,
            )
        return dict_cls()

class ModelSchemaMeta(SchemaMeta):