diff --git a/evennia/contrib/menusystem.py b/evennia/contrib/menusystem.py index 61764f172e..f243e45fff 100644 --- a/evennia/contrib/menusystem.py +++ b/evennia/contrib/menusystem.py @@ -3,7 +3,7 @@ Evennia menu system. Contribution - Griatch 2011 -> Note that the evennia/utils/menu.py module is probably a better and +> Note that the evennia/utils/evmenu.py module is probably a better and more flexible implementation of a menu system than this. Try that first. diff --git a/evennia/typeclasses/managers.py b/evennia/typeclasses/managers.py index 4b3cfdb73a..5a126f2dda 100644 --- a/evennia/typeclasses/managers.py +++ b/evennia/typeclasses/managers.py @@ -526,37 +526,40 @@ class TypeclassManager(TypedObjectManager): kwargs.update({"db_typeclass_path":self.model.path}) return super(TypedObjectManager, self).get(**kwargs) - def filter(self, **kwargs): + def filter(self, *args, **kwargs): """ Overload of the standard filter function. This filter will limit itself to only the current typeclass. + Args: + args (any): These are passed on as arguments to the default + django filter method. Kwargs: kwargs (any): These are passed on as normal arguments to the default django filter method. Returns: - objects (list): The objects found. + objects (queryset): The objects found. """ kwargs.update({"db_typeclass_path":self.model.path}) - return super(TypedObjectManager, self).filter(**kwargs) + return super(TypedObjectManager, self).filter(*args, **kwargs) - def all(self, **kwargs): + def all(self): """ Overload method to return all matches, filtering for typeclass. - Kwargs: - kwargs (any): These are passed on as normal arguments - to the default django all method (usually none are given). Returns: - objects (list): The objects found. + objects (queryset): The objects found. """ - return super(TypedObjectManager, self).all(**kwargs).filter(db_typeclass_path=self.model.path) + return super(TypedObjectManager, self).all().filter(db_typeclass_path=self.model.path) def _get_subclasses(self, cls): """ Recursively get all subclasses to a class. + + Args: + cls (classoject): A class to get subclasses from. """ all_subclasses = cls.__subclasses__() for subclass in all_subclasses: @@ -584,11 +587,14 @@ class TypeclassManager(TypedObjectManager): kwargs.update({"db_typeclass_path__in":paths}) return super(TypedObjectManager, self).get(**kwargs) - def filter_family(self, **kwargs): + def filter_family(self, *args, **kwargs): """ Variation of filter that allows results both from typeclass and from subclasses of typeclass + Args: + args (any): These are passed on as arguments to the default + django filter method. Kwargs: kwargs (any): These are passed on as normal arguments to the default django filter method. @@ -600,22 +606,19 @@ class TypeclassManager(TypedObjectManager): paths = [self.model.path] + ["%s.%s" % (cls.__module__, cls.__name__) for cls in self._get_subclasses(self.model)] kwargs.update({"db_typeclass_path__in":paths}) - return super(TypedObjectManager, self).filter(**kwargs) + return super(TypedObjectManager, self).filter(*args, **kwargs) - def all_family(self, **kwargs): + def all_family(self): """ Return all matches, allowing matches from all subclasses of the typeclass. - Kwargs: - kwargs (any): These are passed on as normal arguments - to the default django all method (usually none are given). Returns: objects (list): The objects found. """ paths = [self.model.path] + ["%s.%s" % (cls.__module__, cls.__name__) for cls in self._get_subclasses(self.model)] - return super(TypedObjectManager, self).all(**kwargs).filter(db_typeclass_path__in=paths) + return super(TypedObjectManager, self).all().filter(db_typeclass_path__in=paths)