aboutsummaryrefslogtreecommitdiffstats
path: root/object.py
diff options
context:
space:
mode:
Diffstat (limited to 'object.py')
-rw-r--r--object.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/object.py b/object.py
index 86996bc..5b2e35d 100644
--- a/object.py
+++ b/object.py
@@ -92,6 +92,21 @@ class Object :
file.write( child.name + "\n")
file.close()
+ @staticmethod
+ def getPermissionByHash( hash, user ) :
+ path = hash[:2] + '/' + hash[2:]
+ try:
+ file = open( path + '/permissions', 'r' )
+ except IOError :
+ print 'cannot open', path
+ else :
+ for line in file :
+ name, sep, perm = line.rstrip('\n').partition(' ')
+ if name == user :
+ return perm
+
+ return 0
+
def getPermission( self, user ) :
file = open( self.path + '/permissions', 'r' )
@@ -102,7 +117,7 @@ class Object :
return perm
return 0
-
+
def setPermission(self, user, permission ) :
if not self.saved :
self.save()
@@ -130,6 +145,7 @@ if __name__== '__main__' :
x.setPermission( "toto", READ | MODIFY | APPEND )
x.setPermission( "toto2", READ | MODIFY | APPEND )
print x.getPermission("toto")
+ print Object.getPermissionByHash(x.name, "toto")
child = Object({'parent' : x.name, 'author' : 'Zaran'})
child.save()