diff --git a/src/objects/models.py b/src/objects/models.py index 2794a0cf20..e53354f506 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -230,8 +230,7 @@ class ObjectDB(TypedObject): # location getsetter def __location_get(self): "Get location" - loc = _GA(_GA(self, "dbobj"), "db_location") - return _GA(loc, "typeclass") if loc else loc + return self.db_location def __location_set(self, location): "Set location, checking for loops and allowing dbref" diff --git a/src/typeclasses/managers.py b/src/typeclasses/managers.py index 95cee94538..1e389e39b2 100644 --- a/src/typeclasses/managers.py +++ b/src/typeclasses/managers.py @@ -68,13 +68,22 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager): """ return super(TypedObjectManager, self).all(**kwargs).filter(db_typeclass_path=self.model.path) + def _get_subclasses(self, cls): + """ + Recursively get all subclasses to a class + """ + all_subclasses = cls.__subclasses__() + for subclass in all_subclasses: + all_subclasses.extend(self._get_subclasses(subclass)) + return all_subclasses + def get_family(self, **kwargs): """ Variation of get that not only returns the current typeclass but also all subclasses of that typeclass. """ paths = [self.model.path] + ["%s.%s" % (cls.__module__, cls.__name__) - for cls in self.model.__subclasses__()] + for cls in self._get_subclasses(self.model)] kwargs.update({"db_typeclass_path__in":paths}) return super(TypedObjectManager, self).get(**kwargs) @@ -85,7 +94,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager): """ # query, including all subclasses paths = [self.model.path] + ["%s.%s" % (cls.__module__, cls.__name__) - for cls in self.model.__subclasses__()] + for cls in self._get_subclasses(self.model)] kwargs.update({"db_typeclass_path__in":paths}) return super(TypedObjectManager, self).filter(**kwargs) @@ -95,7 +104,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager): the typeclass. """ paths = [self.model.path] + ["%s.%s" % (cls.__module__, cls.__name__) - for cls in self.model.__subclasses__()] + for cls in self._get_subclasses(self.model)] return super(TypedObjectManager, self).all(**kwargs).filter(db_typeclass_path__in=paths)