Adjusted checks for Object/Account to prevent conflicts.
This commit is contained in:
parent
b4a3bae6a9
commit
30bfc36beb
9 changed files with 12 additions and 14 deletions
|
|
@ -2739,7 +2739,7 @@ class CmdExamine(ObjManipCommand):
|
||||||
all_cmdsets = [(cmdset.key, cmdset) for cmdset in current_cmdset.merged_from]
|
all_cmdsets = [(cmdset.key, cmdset) for cmdset in current_cmdset.merged_from]
|
||||||
# we always at least try to add account- and session sets since these are ignored
|
# we always at least try to add account- and session sets since these are ignored
|
||||||
# if we merge on the object level.
|
# if we merge on the object level.
|
||||||
if hasattr(obj, "account") and obj.account:
|
if hasattr(obj, "has_account") and obj.account:
|
||||||
# get Attribute-cmdsets if they exist
|
# get Attribute-cmdsets if they exist
|
||||||
all_cmdsets.extend([(cmdset.key, cmdset) for cmdset in obj.account.cmdset.all()])
|
all_cmdsets.extend([(cmdset.key, cmdset) for cmdset in obj.account.cmdset.all()])
|
||||||
if obj.sessions.count():
|
if obj.sessions.count():
|
||||||
|
|
|
||||||
|
|
@ -723,6 +723,6 @@ class CmdAccess(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
string += "\n|wYour access|n:"
|
string += "\n|wYour access|n:"
|
||||||
string += f"\nCharacter |c{caller.key}|n: {cperms}"
|
string += f"\nCharacter |c{caller.key}|n: {cperms}"
|
||||||
if hasattr(caller, "account"):
|
if hasattr(caller, "has_account"):
|
||||||
string += f"\nAccount |c{caller.account.key}|n: {pperms}"
|
string += f"\nAccount |c{caller.account.key}|n: {pperms}"
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
has_sub = self.subscriptions.has(subscriber)
|
has_sub = self.subscriptions.has(subscriber)
|
||||||
if not has_sub and hasattr(subscriber, "account"):
|
if not has_sub and hasattr(subscriber, "has_account"):
|
||||||
# it's common to send an Object when we
|
# it's common to send an Object when we
|
||||||
# by default only allow Accounts to subscribe.
|
# by default only allow Accounts to subscribe.
|
||||||
has_sub = self.subscriptions.has(subscriber.account)
|
has_sub = self.subscriptions.has(subscriber.account)
|
||||||
|
|
|
||||||
|
|
@ -646,8 +646,6 @@ class SubscriptionHandler:
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if hasattr(obj, "account") and obj.account:
|
|
||||||
obj = obj.account
|
|
||||||
if not obj.is_connected:
|
if not obj.is_connected:
|
||||||
continue
|
continue
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
|
|
|
||||||
|
|
@ -515,7 +515,7 @@ def is_ooc(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
function will still return True.
|
function will still return True.
|
||||||
"""
|
"""
|
||||||
obj = accessed_obj.obj if hasattr(accessed_obj, "obj") else accessed_obj
|
obj = accessed_obj.obj if hasattr(accessed_obj, "obj") else accessed_obj
|
||||||
account = obj.account if hasattr(obj, "account") else obj
|
account = obj.account if hasattr(obj, "has_account") else obj
|
||||||
if not account:
|
if not account:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ class LockHandler:
|
||||||
if not no_superuser_bypass and (
|
if not no_superuser_bypass and (
|
||||||
(hasattr(accessing_obj, "is_superuser") and accessing_obj.is_superuser)
|
(hasattr(accessing_obj, "is_superuser") and accessing_obj.is_superuser)
|
||||||
or (
|
or (
|
||||||
hasattr(accessing_obj, "account")
|
hasattr(accessing_obj, "has_account")
|
||||||
and hasattr(accessing_obj.account, "is_superuser")
|
and hasattr(accessing_obj.account, "is_superuser")
|
||||||
and accessing_obj.account.is_superuser
|
and accessing_obj.account.is_superuser
|
||||||
)
|
)
|
||||||
|
|
@ -627,7 +627,7 @@ class LockHandler:
|
||||||
if no_superuser_bypass and (
|
if no_superuser_bypass and (
|
||||||
(hasattr(accessing_obj, "is_superuser") and accessing_obj.is_superuser)
|
(hasattr(accessing_obj, "is_superuser") and accessing_obj.is_superuser)
|
||||||
or (
|
or (
|
||||||
hasattr(accessing_obj, "account")
|
hasattr(accessing_obj, "has_account")
|
||||||
and hasattr(accessing_obj.account, "is_superuser")
|
and hasattr(accessing_obj.account, "is_superuser")
|
||||||
and accessing_obj.account.is_superuser
|
and accessing_obj.account.is_superuser
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
result (bool): If the permstring is passed or not.
|
result (bool): If the permstring is passed or not.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if hasattr(self, "account"):
|
if hasattr(self, "has_account"):
|
||||||
if (
|
if (
|
||||||
self.account
|
self.account
|
||||||
and self.account.is_superuser
|
and self.account.is_superuser
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ class CmdEvMenuNode(Command):
|
||||||
if _restore(caller):
|
if _restore(caller):
|
||||||
return
|
return
|
||||||
orig_caller = caller
|
orig_caller = caller
|
||||||
caller = caller.account if hasattr(caller, "account") else None
|
caller = caller.account if hasattr(caller, "has_account") else None
|
||||||
menu = caller.ndb._evmenu if caller else None
|
menu = caller.ndb._evmenu if caller else None
|
||||||
if not menu:
|
if not menu:
|
||||||
if caller and _restore(caller):
|
if caller and _restore(caller):
|
||||||
|
|
@ -1497,7 +1497,7 @@ class CmdGetInput(Command):
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
try:
|
try:
|
||||||
getinput = caller.ndb._getinput
|
getinput = caller.ndb._getinput
|
||||||
if not getinput and hasattr(caller, "account"):
|
if not getinput and (hasattr(caller, "has_account")):
|
||||||
getinput = caller.account.ndb._getinput
|
getinput = caller.account.ndb._getinput
|
||||||
if getinput:
|
if getinput:
|
||||||
caller = caller.account
|
caller = caller.account
|
||||||
|
|
@ -1618,7 +1618,7 @@ class CmdYesNoQuestion(Command):
|
||||||
|
|
||||||
def _clean(self, caller):
|
def _clean(self, caller):
|
||||||
del caller.ndb._yes_no_question
|
del caller.ndb._yes_no_question
|
||||||
if not caller.cmdset.has(YesNoQuestionCmdSet) and hasattr(caller, "account"):
|
if not caller.cmdset.has(YesNoQuestionCmdSet) and hasattr(caller, "has_account"):
|
||||||
caller.account.cmdset.remove(YesNoQuestionCmdSet)
|
caller.account.cmdset.remove(YesNoQuestionCmdSet)
|
||||||
else:
|
else:
|
||||||
caller.cmdset.remove(YesNoQuestionCmdSet)
|
caller.cmdset.remove(YesNoQuestionCmdSet)
|
||||||
|
|
@ -1628,7 +1628,7 @@ class CmdYesNoQuestion(Command):
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
try:
|
try:
|
||||||
yes_no_question = caller.ndb._yes_no_question
|
yes_no_question = caller.ndb._yes_no_question
|
||||||
if not yes_no_question and hasattr(caller, "account"):
|
if not yes_no_question and hasattr(caller, "has_account"):
|
||||||
yes_no_question = caller.account.ndb._yes_no_question
|
yes_no_question = caller.account.ndb._yes_no_question
|
||||||
caller = caller.account
|
caller = caller.account
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class CmdMore(Command):
|
||||||
Implement the command
|
Implement the command
|
||||||
"""
|
"""
|
||||||
more = self.caller.ndb._more
|
more = self.caller.ndb._more
|
||||||
if not more and hasattr(self.caller, "account"):
|
if not more and hasattr(self.caller, "has_account"):
|
||||||
more = self.caller.account.ndb._more
|
more = self.caller.account.ndb._more
|
||||||
if not more:
|
if not more:
|
||||||
self.caller.msg("Error in loading the pager. Contact an admin.")
|
self.caller.msg("Error in loading the pager. Contact an admin.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue