示例#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
示例#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)
示例#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
示例#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)
示例#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
示例#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
示例#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
示例#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