Fixes, cleanups and bugfixes in various systems.
This commit is contained in:
parent
1565ac3a72
commit
8770a263ac
7 changed files with 33 additions and 39 deletions
|
|
@ -252,7 +252,7 @@ def attr(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
else:
|
||||
return False
|
||||
except Exception, e:
|
||||
print e
|
||||
#print e
|
||||
# this might happen if we try to compare two things that cannot be compared
|
||||
return False
|
||||
|
||||
|
|
@ -260,14 +260,13 @@ def attr(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
if hasattr(accessing_obj, attrname):
|
||||
if value:
|
||||
return valcompare(str(getattr(accessing_obj, attrname)), value, compare)
|
||||
return getattr(accessing_obj, attrname) # will return Fail on False value etc
|
||||
return bool(getattr(accessing_obj, attrname)) # will return Fail on False value etc
|
||||
# check attributes, if they exist
|
||||
if (hasattr(accessing_obj, 'has_attribute')
|
||||
and accessing_obj.has_attribute(attrname)):
|
||||
if (hasattr(accessing_obj, 'has_attribute') and accessing_obj.has_attribute(attrname)):
|
||||
if value:
|
||||
return (hasattr(accessing_obj, 'get_attribute')
|
||||
and valcompare(accessing_obj.get_attribute(attrname), value, compare))
|
||||
return accessing_obj.get_attribute(attrname) # fails on False/None values
|
||||
return bool(accessing_obj.get_attribute(attrname)) # fails on False/None values
|
||||
return False
|
||||
|
||||
def objattr(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
|
|
@ -358,7 +357,6 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
accessed_obj.location == accessing_obj), or if accessing_obj itself holds an
|
||||
object matching the given key.
|
||||
"""
|
||||
print "holds ..."
|
||||
try:
|
||||
# commands and scripts don't have contents, so we are usually looking
|
||||
# for the contents of their .obj property instead (i.e. the object the
|
||||
|
|
@ -369,7 +367,6 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
contents = accessing_obj.obj.contents
|
||||
except AttributeError:
|
||||
return False
|
||||
print "holds", contents, accessing_obj, accessed_obj
|
||||
|
||||
def check_holds(objid):
|
||||
# helper function. Compares both dbrefs and keys/aliases.
|
||||
|
|
@ -386,11 +383,11 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
else:
|
||||
try:
|
||||
if check_holds(accessed_obj.id):
|
||||
print "holds: accessed_obj.id - True"
|
||||
#print "holds: accessed_obj.id - True"
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
print "holds: accessed_obj.obj.id -", hasattr(accessed_obj, "obj") and check_holds(accessed_obj.obj.id)
|
||||
#print "holds: accessed_obj.obj.id -", hasattr(accessed_obj, "obj") and check_holds(accessed_obj.obj.id)
|
||||
return hasattr(accessed_obj, "obj") and check_holds(accessed_obj.obj.id)
|
||||
|
||||
def superuser(*args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -330,9 +330,11 @@ class LockHandler(object):
|
|||
# we have previously stored the function object and all the args/kwargs as list/dict,
|
||||
# now we just execute them all in sequence. The result will be a list of True/False
|
||||
# statements. Note that there is no eval here, these are normal command calls!
|
||||
true_false = (tup[0](accessing_obj, self.obj, *tup[1], **tup[2]) for tup in func_tup)
|
||||
true_false = (bool(tup[0](accessing_obj, self.obj, *tup[1], **tup[2])) for tup in func_tup)
|
||||
# we now input these True/False list into the evalstring, which combines them with
|
||||
# AND/OR/NOT in order to get the final result
|
||||
#true_false = tuple(true_false)
|
||||
#print accessing_obj, self.obj, access_type, true_false, evalstring, func_tup, raw_string
|
||||
return eval(evalstring % tuple(true_false))
|
||||
else:
|
||||
return default
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue