mirror of
https://github.com/evennia/evennia.git
synced 2026-03-27 10:16:32 +01:00
Made unittest suite finish without errors using new proxy system.
This commit is contained in:
parent
71b6600d87
commit
2782e03478
9 changed files with 73 additions and 60 deletions
|
|
@ -299,6 +299,30 @@ class TypedObject(SharedMemoryModel):
|
|||
# Object manipulation methods
|
||||
#
|
||||
|
||||
def is_typeclass(self, typeclass, exact=True):
|
||||
"""
|
||||
Returns true if this object has this type OR has a typeclass
|
||||
which is an subclass of the given typeclass. This operates on
|
||||
the actually loaded typeclass (this is important since a
|
||||
failing typeclass may instead have its default currently
|
||||
loaded) typeclass - can be a class object or the python path
|
||||
to such an object to match against.
|
||||
|
||||
typeclass - a class or the full python path to the class
|
||||
exact - returns true only
|
||||
if the object's type is exactly this typeclass, ignoring
|
||||
parents.
|
||||
"""
|
||||
if not isinstance(typeclass, basestring):
|
||||
typeclass = typeclass.path
|
||||
|
||||
if exact:
|
||||
return typeclass == self.path
|
||||
else:
|
||||
# check parent chain
|
||||
selfpath = self.path
|
||||
return any(cls for cls in self.__class__.mro() if cls.path == selfpath)
|
||||
|
||||
def swap_typeclass(self, new_typeclass, clean_attributes=False,
|
||||
run_start_hooks=True, no_default=True):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue