Esempio n. 1
0
 def handleMove(self, destPath):
     """Change semantic of MOVE to change resource tags."""
     # path and destPath must be '/by_tag/<tag>/<resname>'
     if not "/by_tag/" in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     if not "/by_tag/" in destPath:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.saveSplit(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     catType, tag, _rest = util.saveSplit(destPath.strip("/"), "/", 2)
     assert catType == "by_tag"
     if not tag in self.data["tags"]:
         self.data["tags"].append(tag)
     return True  # OK
Esempio n. 2
0
 def _splitPath(self, path):
     """Return (tableName, primaryKey) tuple for a request path."""
     if path.strip() in (None, "", "/"):
         return (None, None)
     tableName, primKey = util.saveSplit(path.strip("/"), "/", 1)
     #        _logger.debug("'%s' -> ('%s', '%s')" % (path, tableName, primKey))
     return (tableName, primKey)
Esempio n. 3
0
 def handleMove(self, destPath):
     """Change semantic of MOVE to change resource tags."""
     # path and destPath must be '/by_tag/<tag>/<resname>' 
     if not "/by_tag/" in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     if not "/by_tag/" in destPath:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.saveSplit(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     catType, tag, _rest = util.saveSplit(destPath.strip("/"), "/", 2)
     assert catType == "by_tag"
     if not tag in self.data["tags"]:
         self.data["tags"].append(tag)
     return True # OK
Esempio n. 4
0
    def _splitPath(self, path):
        """Return (tableName, primaryKey) tuple for a request path."""
        if path.strip() in (None, "", "/"):
            return (None, None)
        tableName, primKey = util.saveSplit(path.strip("/"), "/", 1)
#        _logger.debug("'%s' -> ('%s', '%s')" % (path, tableName, primKey))
        return (tableName, primKey)
Esempio n. 5
0
 def handleCopy(self, destPath, depthInfinity):
     """Change semantic of COPY to add resource tags."""
     # destPath must be '/by_tag/<tag>/<resname>'
     if not "/by_tag/" in destPath:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.saveSplit(destPath.strip("/"), "/", 2)
     assert catType == "by_tag"
     if not tag in self.data["tags"]:
         self.data["tags"].append(tag)
     return True  # OK
Esempio n. 6
0
 def handleCopy(self, destPath, depthInfinity):
     """Change semantic of COPY to add resource tags."""
     # destPath must be '/by_tag/<tag>/<resname>' 
     if not "/by_tag/" in destPath:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.saveSplit(destPath.strip("/"), "/", 2)
     assert catType == "by_tag"
     if not tag in self.data["tags"]:
         self.data["tags"].append(tag)
     return True # OK
Esempio n. 7
0
 def handleDelete(self):
     """Change semantic of DELETE to remove resource tags."""
     # DELETE is only supported for the '/by_tag/' collection
     if not "/by_tag/" in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     # path must be '/by_tag/<tag>/<resname>'
     catType, tag, _rest = util.saveSplit(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     return True  # OK
Esempio n. 8
0
 def handleDelete(self):
     """Change semantic of DELETE to remove resource tags."""
     # DELETE is only supported for the '/by_tag/' collection 
     if not "/by_tag/" in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     # path must be '/by_tag/<tag>/<resname>' 
     catType, tag, _rest = util.saveSplit(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     return True # OK