mirror of
https://github.com/evennia/evennia.git
synced 2026-03-27 18:26:32 +01:00
Added a "replace" method to lockhandler, courtesy of patch by user Shell.
This commit is contained in:
parent
a4adc035f2
commit
049cc84be7
1 changed files with 11 additions and 1 deletions
|
|
@ -290,6 +290,16 @@ class LockHandler(object):
|
|||
self.log_obj = None
|
||||
return True
|
||||
|
||||
def replace(self, lockstring, log_obj=None):
|
||||
"Replaces the lockstring entirely."
|
||||
old_lockstring = str(self)
|
||||
self.clear()
|
||||
try:
|
||||
return self.add(lockstring, log_obj)
|
||||
except LockException:
|
||||
self.add(old_lockstring, log_obj)
|
||||
raise
|
||||
|
||||
def get(self, access_type):
|
||||
"get the lockstring of a particular type"
|
||||
return self.locks.get(access_type, None)
|
||||
|
|
@ -386,7 +396,7 @@ class LockHandler(object):
|
|||
or (hasattr(accessing_obj, 'get_player') and (not accessing_obj.get_player() or accessing_obj.get_player().is_superuser))):
|
||||
return True
|
||||
|
||||
locks = self. _parse_lockstring(lockstring)
|
||||
locks = self._parse_lockstring(lockstring)
|
||||
for access_type in locks:
|
||||
evalstring, func_tup, raw_string = locks[access_type]
|
||||
true_false = tuple(tup[0](accessing_obj, self.obj, *tup[1], **tup[2]) for tup in func_tup)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue