[Twisted-Python] [spread] "We're walking, we're walking, we're walking..."
Kevin Turner
acapnotic at twistedmatrix.com
Thu Aug 2 04:30:43 EDT 2001
[Yes, I do intend to spend some more time digesting this and working it
into code and perhaps more english, but that won't get done tonight...
So for now, Share and Enjoy!]
IRC log started Thu Aug 02 00:06:16 2001 (PDT -0700)
* Acapnotic pokes glyph
<glyph> Acapnotic: sorry, did you answer before?
<Acapnotic> glyph: Ok, I started the log ten minutes ago for
you, and so far it mainly consists of descriptions of
thirmite's van =)
<dash> haha
<thirmite> my van is awsome
<dash> "ph34r my l33t v4n"
<thirmite> heh
<glyph> Acapnotic: OK. Let's get started then. :)
<glyph> Acapnotic: What do you want to do with PB?
<Acapnotic> glyph: whiteboard, say. client -> server ->
many-clients. but we can start with just half of that.
<glyph> Acapnotic: OK. First thing you need is a whiteboard
service on the server.
<glyph> Acapnotic: by "service" I literally mean a subclass
of pb.Service
<Acapnotic> a pb.Service, okay. That doesn't have many methods
<glyph> Acapnotic: crap. I think I may have changed some naming here
:-). Does your version say anything about getPerspectiveNamed?
<Acapnotic> glyph: yes, getPerspectiveNamed(self,name) is
the only method
<glyph> Acapnotic: Ok, cool.
<glyph> Acapnotic: So you have to implement that method to
retrieve something that represents a viewer of whiteboards
<glyph> Acapnotic: twisted.reality.plumbing can provide an
example for this.
<glyph> uh, actually twisted.reality.reality.Reality, now
that I think of it :)
<dash> reality, reality, REALITY! (ta-daa!)
<dash> glyph: you have such a way with names
<Acapnotic> "a viewer" probably being a front-end? or the client
that's got a display attached?
<glyph> dash: everybody has a bad day sometimes :-\
<dash> glyph: no, i like it
<dash> it's a as subtle as a jackhammer :)
<glyph> Acapnotic: It's the back-end, not the front-end. We're still
on the server.
<glyph> Acapnotic: whatever you return is the thing that the
authenticated user is going to be able to call methods on; it
should be a subclass of pb.Perspective
<Acapnotic> ah, okay, I was derailed for a moment there getting stuck
on "viewer". but this isn't just a passive thing, it's
what we call on to modify the whiteboard as well, ja?
<glyph> yes
<glyph> hmm, maybe we should do this tomorrow, *AFTER* I check in
these changes
<Acapnotic> no two days the same, eh?
<Acapnotic> glyph: Ok, then don't give me specifics on every method I
need to override. Big picture -- what classes go on which
end, what talks to what?
<glyph> Acapnotic: welll, after hte handshake we just described,
you've got a Perspective on the server
<glyph> the client has a Reference to that Perspective
<glyph> so when the client says perspective.foo(bar, baz), the
server's perspective gets x.perspective_foo(bar, baz) called
on it
<Acapnotic> glyph: Okay. And is this one of your "there are no return
values" areas?
<Acapnotic> yes, because calls are asyncronyous... crap, I can't spell
these days.
<glyph> Acapnotic: Yes. There are no return values; if the client
wants to get a callback when the return value's ready, it
calls p.foo(bar, baz, pbcallback=qux)
<Acapnotic> glyph: So now I can do whiteboard_author_client->server.
To do server->whiteboard_audience_client, will I flip this
around and put a "server" in each client? (a la X)
<glyph> Acapnotic: No need.
<glyph> Acapnotic: You can just have each interested "listener" pass a
subclass of "pb.Referenced" into a remote callback, which
defines a method that the server will call.
<Acapnotic> glyph: so I'm just going to stash a bunch of these
Referenced callbacks in some private attribute, and then
run through them whenever I want to talk at them?
<glyph> Acapnotic: essentially, yes.
<Acapnotic> glyph: now you said these subclasses_of(pb.Referenced)
defined a method to call. Does that mean I should have
them __call__able? Or will I call their methods? Or is
that entirely up to me?
<glyph> Acapnotic: Subclasess of pb.Referenced define methods named
remote_XXX; remoteobj.XXX() on the other side will invoke
those methods.
<Acapnotic> glyph: and I missed a piece of the handshaking. Where did
the client/server connection happen?
<glyph> Acapnotic: that's irrelevant :)
<glyph> the way that happens is just you instantiate a tcp.Client with
a Broker as the protocol
<glyph> all fo these interactions happen through the pb.Broker
<glyph> (requestPerspective, to be precise)
<Acapnotic> ok, that's good to know, I wouldn't call that irrelevant =)
--
"...we're stopped."
More information about the Twisted-Python
mailing list