|
a/Ming/ming/base.py |
|
b/Ming/ming/base.py |
|
... |
|
... |
219 |
mm = cls.__mongometa__ = type('__mongometa__', tuple(mm_bases), mm_dict)
|
219 |
mm = cls.__mongometa__ = type('__mongometa__', tuple(mm_bases), mm_dict)
|
220 |
if not hasattr(mm, 'polymorphic_on'):
|
220 |
if not hasattr(mm, 'polymorphic_on'):
|
221 |
mm.polymorphic_on = None
|
221 |
mm.polymorphic_on = None
|
222 |
mm.polymorphic_registry = None
|
222 |
mm.polymorphic_registry = None
|
223 |
# Make sure mongometa's schema incorporates base schemas
|
223 |
# Make sure mongometa's schema incorporates base schemas
|
224 |
fields = dict()
|
224 |
my_schema = schema.Object()
|
225 |
for base in mm_bases:
|
225 |
for base in mm_bases:
|
226 |
if hasattr(base, 'schema'):
|
226 |
if hasattr(base, 'schema'):
|
227 |
if base.schema:
|
227 |
if base.schema:
|
228 |
fields.update(base.schema.fields)
|
228 |
my_schema.extend(schema.SchemaItem.make(base.schema))
|
229 |
if mm.schema:
|
229 |
if mm.schema:
|
230 |
my_schema = schema.SchemaItem.make(mm.schema, inherited_fields=fields)
|
|
|
231 |
else:
|
|
|
232 |
my_schema = schema.SchemaItem.make(fields)
|
230 |
my_schema.extend(schema.SchemaItem.make(mm.schema))
|
233 |
# Collect fields
|
231 |
# Collect fields
|
234 |
for k,v in dct.iteritems():
|
232 |
for k,v in dct.iteritems():
|
235 |
if isinstance(v, Field):
|
233 |
if isinstance(v, Field):
|
236 |
v.name = k
|
234 |
v.name = k
|
237 |
si = schema.SchemaItem.make(v.type, *v.args, **v.kwargs)
|
235 |
si = schema.SchemaItem.make(v.type, *v.args, **v.kwargs)
|