[Twisted-Python] Wrapping my mind around Interfaces, adapters, factories, protocols

Ron Arts ron.arts at netland.nl
Tue Oct 31 19:26:44 EST 2006


Hi,

I am trying to accomplish the following:

- have a client connecting to a remote service
   and collecting information from it
- have a service that can be queried for the collected
   info

But I am getting totally confused with all the interface classes,
adapters, factories, protocols I should write according to the
finger tutorial.
I skimmed the mailinglist, but to no avail.

My app is laid out almost like the finger tutorial (I left out
the web, and PB parts for now), the biggest difference being that
the client data should be available to the service that is
being queried.

So I thought that instead of first create the finger service in
the makeService() method, I would first create a TCP client, and
pass that to a service to be created later.

something like:

def makeService(config):
     s = service.MultiService()

     m = MyClient()
     m.username = 'username'
     m.password = 'password'
     theserver = '192.168.1.2'
     b = internet.TCPClient(theserver, 6666, IMyClientFactory(m))
     b.setServiceParent(s)

     return s

But for this to work I have to create interfacethis, protocol that,
and use components.registerAdapter(), to do something I totally don't
understand what it does and why it needs to be done,
I have read the finger example many times, but I can't seem to wrap
my mind around these concepts, in the little time I have available.
Can anybody whip me up a supershort example in pseudo code of what I
need to do to make the above makeService work? And explain it a bit?

Many thanks,
Ron


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ron.arts.vcf
Type: text/x-vcard
Size: 270 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20061101/47ddcbb6/attachment.vcf 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3403 bytes
Desc: S/MIME Cryptographic Signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20061101/47ddcbb6/attachment.bin 


More information about the Twisted-Python mailing list