[Twisted-Python] How to hook at StandardIO factory to a twistd app
Alex Clemesha
clemesha at gmail.com
Wed Apr 8 13:11:29 EDT 2009
On Wed, Apr 8, 2009 at 9:14 AM, <akrherz at iastate.edu> wrote:
> Hi Twisted!
>
> Could a kind soul provide me an example of how to connect my StandardIO
> factory to a twistd app? Here is an overview of my code
>
> class MyProtocol(basic.LineReceiver):
> # Blah Blah
>
> class MyFactory( stdio.StandardIO ):
> def __init__(self, protocol):
> self.protocol = protocol
>
> # then by .tac has
> application = service.Application("Ingestor")
> serviceCollection = service.IServiceCollection(application)
>
> proto = MyProtocol()
> factory = MyFactory( proto )
>
>
> It is not clear to me how to connect my factory to the application, I do
> this many other times for network related factories by connecting via a
> TCPServer or TCPClient .
Looks like all you need to do is add this import:
from twisted.application import internet
and then do:
port = 8080 #or whatever
internet.TCPServer(port, factory).setServiceParent(serviceCollection)
hope this helps,
Alex
>
> Sorry for what I suspect is an embarrassingly simple question. :(
>
> thank you!
> daryl
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
--
Alex Clemesha
clemesha.org
More information about the Twisted-Python
mailing list