def factory(cls, collection_name, object_id=None): if object_id is None: return Docs.installed[collection_name]() man = cls.installed[collection_name].manager raw = man.o.find_one(helper.object_id(object_id)) doc_key = man.db_name if '_subtype' in raw: subtype = raw.pop('_subtype') doc_key = "%s:%s" % (man.db_name, subtype) if doc_key not in Docs.installed: raise DeveloperFault("Unknown document type:%s" % doc_key) o = cls.installed[doc_key]() o.inflate(raw) return o
def __init__(self, object_id=None): super(Doc, self).__init__() self.object_id = helper.object_id(object_id) self._injected_object_id = None self.load()