Example #1
0
 def __call__(self):
     if vfs.exists(self.destination):
         if not self.overwrite:
             raise exc.HTTPPreconditionFailed(explanation='The destination URL is already mapped to a resource and Overwrite is F.')
         else:
             if vfs.isdir(self.destination):
                 vfs.removedir(self.destination, recursive=True)
             else:
                 vfs.remove(self.destination)
     ##FIXME: no Insufficient Storage notification
     if vfs.isdir(self.source):
         ##TODO: check for recursion (/A -> /A/B) or same resource (/A -> /A)
         #if ??RECURSION??:
         #    raise exc.HTTPForbidden(explanation='No recursion allowed.')
         if self.depth == 'infinity':
             try:
                 if self.copy_or_move == 'copy':
                     vfs.copydir(self.source, self.destination)
                 elif self.copy_or_move == 'move':
                     vfs.movedir(self.source, self.destination)
             except FSError, e:
                 ##FIXME: explanation too verbose?
                 raise exc.HTTPForbidden(explanation=str(e))
         elif self.depth == '0':
             raise exc.HTTPBadRequest(explanation='A depth of 0 is not implemented for collections.')
Example #2
0
 def __call__(self):
     try:
         if vfs.isdir(self.path):
             if self.depth == 'infinity':
                 recursive=True
             else:
                 recursive=False
             vfs.removedir(self.path, recursive=recursive)
         else:
             vfs.remove(self.path)
     except FSError, e:
         ##FIXME: explanation too verbose?
         raise exc.HTTPForbidden(explanation=str(e))