Minor tidyup

This commit is contained in:
Harry Marr 2010-01-26 19:36:19 +00:00
parent 568000805f
commit bca6119db8

View File

@ -345,19 +345,15 @@ class BaseDocument(object):
if value is not None: if value is not None:
data[field.name] = field.to_mongo(value) data[field.name] = field.to_mongo(value)
# Only add _cls and _types if allow_inheritance is not False # Only add _cls and _types if allow_inheritance is not False
#if not (hasattr(self, '_meta') and if not (hasattr(self, '_meta') and
# self._meta.get('allow_inheritance', True) == False): self._meta.get('allow_inheritance', True) == False):
ah = True
if hasattr(self, '_meta'):
ah = self._meta.get('allow_inheritance', True)
if ah:
data['_cls'] = self._class_name data['_cls'] = self._class_name
data['_types'] = self._superclasses.keys() + [self._class_name] data['_types'] = self._superclasses.keys() + [self._class_name]
return data return data
@classmethod @classmethod
def _from_son(cls, son): def _from_son(cls, son):
"""Create an instance of a Document (subclass) from a PyMongo SOM. """Create an instance of a Document (subclass) from a PyMongo SON.
""" """
# get the class name from the document, falling back to the given # get the class name from the document, falling back to the given
# class if unavailable # class if unavailable