transfer server

Robert Olson olson at
Thu Feb 20 16:31:37 CST 2003

the refactored transfer server should do what you want now. I'm waiting to 
commit changes until ivan gets his fixes in, but here is what the code will 
sort of look lke (from teh bottom of the datastore module).

What you'd do is define a handler class that answers GetDownloadFilename 
with the pathname of the things you want to export. The URLs to those 
things are generated by calling the GetDownloadDescriptor method on the 
transfer server. You'll need to register a prefix for your downloads like I 
do below.

If you have CanUploadFile return 0 and GetUploadFilename returnm, upload 
attempts will fail.


     s = GSIHTTPTransferServer(('', 9011))

     class Handler:
         def GetDownloadFilename(self, id_token, url_path):
             print "Get download: id='%s' path='%s'" % (id_token, url_path)
             return r"c:\temp\junoSetup.exe"

         def GetUploadFilename(self, id_token, file_info):
             print "Get upload filename for %s %s" % (id_token, file_info)
             return os.path.join("c:\\", "temp", "uploads", file_info['name'])

         def CanUploadFile(self, id_token, file_info):
             print "CanUpload: id=%s file_info=%s" % (id_token, file_info)
             return 1

         def AddPendingUpload(self, id_token, filename):
             print "AddPendingUpload: %s %s" % (id_token, filename)

         def CompleteUpload(self, id_token, file_info):
             print "CompleteUpload %s %s" % (id_token, file_info)

     prefix = "test"
     s.RegisterPrefix(prefix, Handler())

     print s.GetDownloadDescriptor(prefix, "JunoSetup.exe")
     print s.GetUploadDescriptor(prefix)

         while 1:


More information about the ag-dev mailing list