Adjusting checks to use utils.inherits_from()
This commit is contained in:
parent
30bfc36beb
commit
26643a71a7
8 changed files with 26 additions and 15 deletions
|
|
@ -18,6 +18,7 @@ from ast import literal_eval
|
|||
|
||||
from django.conf import settings
|
||||
|
||||
import evennia
|
||||
from evennia.utils import utils
|
||||
|
||||
_PERMISSION_HIERARCHY = [pe.lower() for pe in settings.PERMISSION_HIERARCHY]
|
||||
|
|
@ -515,7 +516,7 @@ def is_ooc(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
function will still return True.
|
||||
"""
|
||||
obj = accessed_obj.obj if hasattr(accessed_obj, "obj") else accessed_obj
|
||||
account = obj.account if hasattr(obj, "has_account") else obj
|
||||
account = obj.account if utils.inherits_from(obj, evennia.DefaultObject) else obj
|
||||
if not account:
|
||||
return True
|
||||
try:
|
||||
|
|
@ -657,7 +658,7 @@ def has_account(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
This is a useful lock for traverse-locking Exits to restrain NPC
|
||||
mobiles from moving outside their areas.
|
||||
"""
|
||||
return hasattr(accessing_obj, "has_account") and accessing_obj.has_account
|
||||
return utils.inherits_from(accessing_obj, evennia.DefaultObject) and accessing_obj.has_account
|
||||
|
||||
|
||||
def serversetting(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ import re
|
|||
from django.conf import settings
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
import evennia
|
||||
from evennia.utils import logger, utils
|
||||
|
||||
__all__ = ("LockHandler", "LockException")
|
||||
|
|
@ -553,7 +554,7 @@ class LockHandler:
|
|||
if not no_superuser_bypass and (
|
||||
(hasattr(accessing_obj, "is_superuser") and accessing_obj.is_superuser)
|
||||
or (
|
||||
hasattr(accessing_obj, "has_account")
|
||||
utils.inherits_from(accessing_obj, evennia.DefaultObject)
|
||||
and hasattr(accessing_obj.account, "is_superuser")
|
||||
and accessing_obj.account.is_superuser
|
||||
)
|
||||
|
|
@ -627,7 +628,7 @@ class LockHandler:
|
|||
if no_superuser_bypass and (
|
||||
(hasattr(accessing_obj, "is_superuser") and accessing_obj.is_superuser)
|
||||
or (
|
||||
hasattr(accessing_obj, "has_account")
|
||||
utils.inherits_from(accessing_obj, evennia.DefaultObject)
|
||||
and hasattr(accessing_obj.account, "is_superuser")
|
||||
and accessing_obj.account.is_superuser
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue