OPSI.web2.dav.fileop module¶
WebDAV file operations
This API is considered private to static.py and is therefore subject to change.
-
OPSI.web2.dav.fileop.
delete
(uri, filepath, depth='infinity')¶ Perform a X{DELETE} operation on the given URI, which is backed by the given filepath. @param filepath: the L{FilePath} to delete. @param depth: the recursion X{Depth} for the X{DELETE} operation, which must
be “infinity”.- @raise HTTPError: (containing a response with a status code of
- L{responsecode.BAD_REQUEST}) if C{depth} is not “infinity”.
- @raise HTTPError: (containing an appropriate response) if the
- delete operation fails. If C{filepath} is a directory, the response will be a L{MultiStatusResponse}.
- @return: a deferred response with a status code of L{responsecode.NO_CONTENT}
- if the X{DELETE} operation succeeds.
-
OPSI.web2.dav.fileop.
copy
(*args, **kwargs)¶ Perform a X{COPY} from the given source and destination filepaths. This will perform a X{DELETE} on the destination if necessary; the caller should check and handle the X{overwrite} header before calling L{copy} (as in L{COPYMOVE.prepareForCopy}). @param source_filepath: a L{FilePath} for the file to copy from. @param destination_filepath: a L{FilePath} for the file to copy to. @param destination_uri: the URI of the destination resource. @param depth: the recursion X{Depth} for the X{COPY} operation, which must
be one of “0”, “1”, or “infinity”.- @raise HTTPError: (containing a response with a status code of
- L{responsecode.BAD_REQUEST}) if C{depth} is not “0”, “1” or “infinity”.
- @raise HTTPError: (containing an appropriate response) if the operation
- fails. If C{source_filepath} is a directory, the response will be a L{MultiStatusResponse}.
- @return: a deferred response with a status code of L{responsecode.CREATED}
- if the destination already exists, or L{responsecode.NO_CONTENT} if the destination was created by the X{COPY} operation.
-
OPSI.web2.dav.fileop.
move
(*args, **kwargs)¶ Perform a X{MOVE} from the given source and destination filepaths. This will perform a X{DELETE} on the destination if necessary; the caller should check and handle the X{overwrite} header before calling L{copy} (as in L{COPYMOVE.prepareForCopy}). Following the X{DELETE}, this will attempt an atomic filesystem move. If that fails, a X{COPY} operation followed by a X{DELETE} on the source will be attempted instead. @param source_filepath: a L{FilePath} for the file to copy from. @param destination_filepath: a L{FilePath} for the file to copy to. @param destination_uri: the URI of the destination resource. @param depth: the recursion X{Depth} for the X{MOVE} operation, which must
be “infinity”.- @raise HTTPError: (containing a response with a status code of
- L{responsecode.BAD_REQUEST}) if C{depth} is not “infinity”.
- @raise HTTPError: (containing an appropriate response) if the operation
- fails. If C{source_filepath} is a directory, the response will be a L{MultiStatusResponse}.
- @return: a deferred response with a status code of L{responsecode.CREATED}
- if the destination already exists, or L{responsecode.NO_CONTENT} if the destination was created by the X{MOVE} operation.
-
OPSI.web2.dav.fileop.
put
(*args, **kwargs)¶ Perform a PUT of the given data stream into the given filepath. @param stream: the stream to write to the destination. @param filepath: the L{FilePath} of the destination file. @param uri: the URI of the destination resource.
If the destination exists, if C{uri} is not C{None}, perform a X{DELETE} operation on the destination, but if C{uri} is C{None}, delete the destination directly. Note that whether a L{put} deletes the destination directly vs. performing a X{DELETE} on the destination affects the response returned in the event of an error during deletion. Specifically, X{DELETE} on collections must return a L{MultiStatusResponse} under certain circumstances, whereas X{PUT} isn’t required to do so. Therefore, if the caller expects X{DELETE} semantics, it must provide a valid C{uri}.- @raise HTTPError: (containing an appropriate response) if the operation
- fails.
- @return: a deferred response with a status code of L{responsecode.CREATED}
- if the destination already exists, or L{responsecode.NO_CONTENT} if the destination was created by the X{PUT} operation.
-
OPSI.web2.dav.fileop.
mkcollection
(filepath)¶ Perform a X{MKCOL} on the given filepath. @param filepath: the L{FilePath} of the collection resource to create. @raise HTTPError: (containing an appropriate response) if the operation
fails.- @return: a deferred response with a status code of L{responsecode.CREATED}
- if the destination already exists, or L{responsecode.NO_CONTENT} if the destination was created by the X{MKCOL} operation.