Пример #1
0
 def _split_path(self, path):
     """Return (tableName, primaryKey) tuple for a request path."""
     if path.strip() in (None, "", "/"):
         return (None, None)
     tableName, primKey = util.save_split(path.strip("/"), "/", 1)
     #        _logger.debug("'%s' -> ('%s', '%s')" % (path, tableName, primKey))
     return (tableName, primKey)
Пример #2
0
 def handle_move(self, dest_path):
     """Change semantic of MOVE to change resource tags."""
     # path and destPath must be '/by_tag/<tag>/<resname>'
     if "/by_tag/" not in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     if "/by_tag/" not in dest_path:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.save_split(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     catType, tag, _rest = util.save_split(dest_path.strip("/"), "/", 2)
     assert catType == "by_tag"
     if tag not in self.data["tags"]:
         self.data["tags"].append(tag)
     return True  # OK
Пример #3
0
 def handle_move(self, dest_path):
     """Change semantic of MOVE to change resource tags."""
     # path and destPath must be '/by_tag/<tag>/<resname>'
     if "/by_tag/" not in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     if "/by_tag/" not in dest_path:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.save_split(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     catType, tag, _rest = util.save_split(dest_path.strip("/"), "/", 2)
     assert catType == "by_tag"
     if tag not in self.data["tags"]:
         self.data["tags"].append(tag)
     return True  # OK
Пример #4
0
 def handle_copy(self, dest_path, depth_infinity):
     """Change semantic of COPY to add resource tags."""
     # destPath must be '/by_tag/<tag>/<resname>'
     if "/by_tag/" not in dest_path:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.save_split(dest_path.strip("/"), "/", 2)
     assert catType == "by_tag"
     if tag not in self.data["tags"]:
         self.data["tags"].append(tag)
     return True  # OK
Пример #5
0
 def handle_copy(self, dest_path, depth_infinity):
     """Change semantic of COPY to add resource tags."""
     # destPath must be '/by_tag/<tag>/<resname>'
     if "/by_tag/" not in dest_path:
         raise DAVError(HTTP_FORBIDDEN)
     catType, tag, _rest = util.save_split(dest_path.strip("/"), "/", 2)
     assert catType == "by_tag"
     if tag not in self.data["tags"]:
         self.data["tags"].append(tag)
     return True  # OK
Пример #6
0
 def handle_delete(self):
     """Change semantic of DELETE to remove resource tags."""
     # DELETE is only supported for the '/by_tag/' collection
     if "/by_tag/" not in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     # path must be '/by_tag/<tag>/<resname>'
     catType, tag, _rest = util.save_split(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     return True  # OK
Пример #7
0
 def handle_delete(self):
     """Change semantic of DELETE to remove resource tags."""
     # DELETE is only supported for the '/by_tag/' collection
     if "/by_tag/" not in self.path:
         raise DAVError(HTTP_FORBIDDEN)
     # path must be '/by_tag/<tag>/<resname>'
     catType, tag, _rest = util.save_split(self.path.strip("/"), "/", 2)
     assert catType == "by_tag"
     assert tag in self.data["tags"]
     self.data["tags"].remove(tag)
     return True  # OK