No subject
Wed Feb 23 11:29:31 MST 2011
h =3D internet.TCPServer(79, IFingerFactory(f))
notice IFingerFactory? If you read the earlier parts of the tutorial,
you'll see stuff like components.registerAdapter. It's just magic to
create a FingerFactoryFromService, giving its constructor f, the
"Finger Service". What happens here is that "f", the Finger Service,
is different from the service.Service within the Twisted Framework.
You might as well call "f", the Finger Service, "Finger Shared Data".
What really happens here is
h is the service that has parent s, MultiService. s is then returned
and started by the application.
h contains a factory that gets run.
The factory knows "f", the Finger Service, which has nothing to do
with twisted's mechanism. It's more of a demo for the component based
framework. f is a way to share data and methods and states across
multiple factories.
I am also very new to twisted, so I **hope** this understanding of
mine is correct ...
I strongly recommend you read through the entire tutorial. They build
very incrementally, so most of the time the code is repeated so you
can just skim through it if you had started from the beginning.
David Kao
On Fri, Sep 30, 2011 at 5:28 AM, Dorian Raymer <deldotdr at gmail.com> wrote:
> Hello,
> I am confused about how the FingerService gets started in the
> finger/finger.py makeService function. It is never assigned a service par=
ent
> and it can't service getUser requests if its startService method isn't
> called; you get an AttributeError:=A0"no attribute 'users'" the way it wo=
rks
> now. Is this a bug?
> The most sensible thing, in this case, seems to be setting the FingerServ=
ice
> parent to be the MultiService container that all of the interent services
> are added to in the makeService function.=A0Is that correct?
> I'm wondering if their are any other=A0strategies people use for starting
> non-internet services.
> For instance, if instead of reading a file to get to my user db, I might
> want to start a redis client and read from redis to service a getUser cal=
l.
> But that means I'd want to make sure the startService=A0call succeeded (t=
he
> redis connection was made) before one of the internet services tries to u=
se
> the FingerService (a timing problem that doesn't exist when just reading =
a
> file)...or something. Maybe I'm really just wondering how the twisted
> application framework handles exceptions that occur for startService call=
s.
> Maybe I need something else to handle that kind of thing?
> I'm also wondering if it's ever a good idea to make a extension
> of=A0ServerFactory=A0(that adapts a Service)=A0that calls=A0Service.start=
Service
> when Factory.startServer is called (and Service.stopService when
> Factory.stopFactory is called)?
> And I'm looking for more use cases/projects (beyond the finger tutorial)
> that really showcase the twisted application framework. Any references wo=
uld
> be appreciated!
> Thanks!
> -Dorian
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
More information about the Twisted-Python
mailing list