mirror of
https://github.com/evennia/evennia.git
synced 2026-04-06 07:57:16 +02:00
Moved permissions into a the tag system as a separate handler. Permissions still don't work quite right yet.
This commit is contained in:
parent
2acff2d1ab
commit
06e858b3f6
21 changed files with 1003 additions and 389 deletions
|
|
@ -146,13 +146,13 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
|
||||
try:
|
||||
perm = args[0].lower()
|
||||
perms_object = [p.lower() for p in accessing_obj.permissions]
|
||||
perms_object = [p.lower() for p in accessing_obj.permissions.all()]
|
||||
except (AttributeError, IndexError):
|
||||
return False
|
||||
|
||||
if utils.inherits_from(accessing_obj, "src.objects.objects.Object") and accessing_obj.player:
|
||||
player = accessing_obj.player
|
||||
perms_player = [p.lower() for p in player.permissions]
|
||||
perms_player = [p.lower() for p in player.permissions.all()]
|
||||
is_quell = player.get_attribute("_quell")
|
||||
|
||||
if perm in _PERMISSION_HIERARCHY:
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Example:
|
|||
"Checking if the object has a particular, desired permission"
|
||||
if args:
|
||||
desired_perm = args[0]
|
||||
return desired_perm in accessing_obj.permissions
|
||||
return desired_perm in accessing_obj.permissions.all()
|
||||
return False
|
||||
|
||||
Lock functions should most often be pretty general and ideally possible to
|
||||
|
|
@ -429,7 +429,7 @@ def _test():
|
|||
|
||||
pdb.set_trace()
|
||||
obj1.locks = LockHandler(obj1)
|
||||
obj2.permissions = ["Immortals"]
|
||||
obj2.permissions.add("Immortals")
|
||||
obj2.id = 4
|
||||
|
||||
#obj1.locks.add("edit:attr(test)")
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class TestLockCheck(LockTest):
|
|||
def testrun(self):
|
||||
dbref = self.obj2.dbref
|
||||
self.obj1.locks.add("owner:dbref(%s);edit:dbref(%s) or perm(Wizards);examine:perm(Builders) and id(%s);delete:perm(Wizards);get:all()" % (dbref, dbref, dbref))
|
||||
self.obj2.permissions = ['Wizards']
|
||||
self.obj2.permissions.add('Wizards')
|
||||
self.assertEquals(True, self.obj1.locks.check(self.obj2, 'owner'))
|
||||
self.assertEquals(True, self.obj1.locks.check(self.obj2, 'edit'))
|
||||
self.assertEquals(True, self.obj1.locks.check(self.obj2, 'examine'))
|
||||
|
|
@ -47,7 +47,7 @@ class TestLockCheck(LockTest):
|
|||
self.assertEquals(True, self.obj1.locks.check(self.obj2, 'not_exist', default=True))
|
||||
class TestLockfuncs(LockTest):
|
||||
def testrun(self):
|
||||
self.obj2.permissions = ['Wizards']
|
||||
self.obj2.permissions.add('Wizards')
|
||||
self.assertEquals(True, lockfuncs.true(self.obj2, self.obj1))
|
||||
self.assertEquals(False, lockfuncs.false(self.obj2, self.obj1))
|
||||
self.assertEquals(True, lockfuncs.perm(self.obj2, self.obj1, 'Wizards'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue