Package AccessGrid :: Module DataStore :: Class TransferServer
[show private | hide private]
[frames | no frames]

Class TransferServer

Known Subclasses:
GSIHTTPTransferServer, HTTPTransferServer

A TransferServer provides file upload and download services.

It is intended to be subclassed to produce a protocol-specific
transfer engine. This class handles the connection to the data
store itself, and the manipulation of manifests.

The transfer server provides services based on URL prefixes. That
is, a client (um, a client in the same process as this object that
is using its services to provide file upload and download
capabilities) of the transfer server will register its interest in
upload and downloads for some URL prefix. Access to files under
that prefix is gated through the registered object.

A local client registers a callback handler with the
TransferServer. This handler will be invoked in the following
situations:

When a HTTP GET request occurs to initiate a file download, the
handler's GetDownloadFilename(id_token, url_path) is invoked, and
expects to be returned a pathname to the file on the local
filesystem. The url_path does not include the client's transfer
prefix. id_token is an identifier token representing the identity
of the downloading client.

When a HTTP POST request occurs with a transfer manifest, the
manifest is parsed. For each file, the handler's
CanUpload(id_token, file_info) callback is invoked.  The callback
is to determine whether it can accept the upload of the file and
return 1 if the server will accept the file, 0 otherwise. id_token
is an identifier token representing the identity of the uploading
client.

file_info is a dictionary with the following keys:

    name            Desired name of the file
    size            Size of the file in bytes
    checksum        MD5 checksum of the file

If the manifest processing indicates that the file upload can
continue, the transfer handler's AddPendingUpload(id_token,
filename) method is invoked.

When a HTTP POST request occurs with an actual file upload, the
handler's GetUploadFilename(id_token, file_info) method is
invoked. The handler validates the request and returns the
pathname to which the file should be uploaded. id_token is an
identifier token representing the identity of the uploading
client.

When the file upload is completed, the handler's
CompleteUpload(id_token, file_info) method is invoked.

Method Summary
  __init__(self)
  GetDownloadDescriptor(self, prefix, path)
Return the download descriptor for this transfer server.
  GetUploadDescriptor(self, prefix)
Return the upload descriptor for this transfer server.
  LookupPrefix(self, prefix)
  LookupUploadInformation(self, transfer_key, file_num)
Look up the information for transfer_key and file_num in the manifest.
  RegisterManifest(self, manifest)
A client has sent a POST to /<prefix>/manifest to initiate an upload.
  RegisterPrefix(self, prefix, handler)

Method Details

GetDownloadDescriptor(self, prefix, path)

Return the download descriptor for this transfer server.

Must be implemented by the protocol-specific subclass.

GetUploadDescriptor(self, prefix)

Return the upload descriptor for this transfer server.

Must be implemented by the protocol-specific subclass.

LookupUploadInformation(self, transfer_key, file_num)

Look up the information for transfer_key and file_num in the manifest.

Raise a FileNotFound exception if it isn't there.

Returns the list of attribute information for that file.

RegisterManifest(self, manifest)

A client has sent a POST to /<prefix>/manifest to initiate an upload. Manifest is the manifest that was transferred.

Allocate a transfer key for this upload, save the manifest under that key, and return the key to the caller.

Generated by Epydoc 2.1 on Thu Apr 14 16:39:32 2005 http://epydoc.sf.net