delegate the permission decision to the resource
[jelmer/calypso.git] / calypso / webdav.py
index b3ea38de242ff9315ab2d604f45f3244f544b5c5..b80ac74345947efa7a0116aa365f2e579d614bf4 100644 (file)
@@ -38,7 +38,7 @@ import subprocess
 
 import ConfigParser
 
-from . import config, paths
+from . import config, paths, acl
 
 METADATA_FILENAME = ".calypso-collection"
 
@@ -228,7 +228,7 @@ class CalypsoError(Exception):
     def __str__(self):
         return "%s: %s" % (self.reason, self.file)
 
-class Collection(object):
+class Collection(acl.Entity):
     """Internal collection class."""
 
     def get_description(self):
@@ -632,3 +632,9 @@ class Collection(object):
             return self.metadata.getboolean('collection', 'personal')
         except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
             return config.get('acl', 'personal')
+
+    def has_right(self, user):
+        try:
+            return user in self.metadata.get('collection', 'allowed-users').split()
+        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
+            return super(Collection, self).has_right(user)