[Twisted-Python] rfc: pb filetransfers
typo at soniq.net
Thu Aug 29 13:34:56 EDT 2002
My approach to doing pb filetransfers is attached,
this code should illustrate the basic idea:
# A Session is a chain of Jobs that are carried out in order,
# one after another.
# The server builds a custom Session from Mixins, to provide
# only the jobs he wants to accept. ServerSession is the base
# class (pb.Viewable).
# FileSSM is the ServerSessionMixin for Filetransfers.
class FileSession(session.ServerSession, session.FileSSM):
# Then that class is offered to clients via callRemote.
# That's all, the server now provides file transfer functionality
# to clients.
# Client builds a Custom Session too.
# FileCSM is the ClientSessionMixin for Filetransfers,
# CallableCSM provides session.call(func, args)
# which is used to call a function after some other
# job has completed (e.g. a file download)
class MySession(session.ClientSession, session.FileCSM, session.CallableCSM):
# Then a session is requested from the server, and the received
# deferred is wrapped by MySession. After that we can queue jobs
# on the session.
session = MySession(perspective.callRemote("getsession"))
session.call(woot, "Done with Session.")
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2421 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020829/5b40312e/attachment.bin
More information about the Twisted-Python