[Twisted-Python] Unpersistable instead of pb.Avatar

Daniel Sank sank.daniel at gmail.com
Sun Dec 1 09:25:29 MST 2013


>> It doesn't make sense to use the same perspective in
>> both games
>>
> I don't see why not personally.

I can think of two reasons. First, suppose that I would like to
participate in two different games of chess at the same time. Suppose
my Avatar class has a method for moving the chess pieces

perspective_movePjece(startSquare, endSquare)

If it is possible that this Avatar is playing more than one game then
this method doesn't have enough context to get the job done. Either I
have to use two method calls

perspective_selectGame(nameOfGameICareAboutNow):
    self.nameOfSelectedGame = nameOfGameICareAboutNow

perspective_movePiece(startSquare, endSquare)

or I have to require that the client side call pass in the game as an argument

perspective.callRemote("movePiece", startSquare, endSquare, whichGame)

I find both of these unsatisfying. In the first case I've basically
reverted to a remote procedure call style interface with calls that
aren't even atomic, and in the second I require the user to explicitly
declare the context of the call. This seems to miss the point of
remote objects. I'd much rather have the games be instances of
Viewable and have different perspectives into each one so that
invocations of callRemote on my references to those Viewables
automatically come with the proper context. This is why I want
multiple Avatars per human user.

The second reason is that one human may want to play as two distinct
players in the same game. In that case I need to be able to change my
client side representation of the published objects as the human
switches between the players. Here again we need multiple perspectives
to get the job done.

> Your Avatar is supposed to represente a "user" after that,
> it is up to you to define what a "User" is for your application.
> If a "user" is a "physical person", so your avatar could play
> several games at once, your avatar could then have a list of
> "played games" (for examples).

I explain above why I don't like this solution.

> If your "user" is a couple of ("physical person"  + "a game")
> so each person playing a game will represent a different
> "user" in the point of view of your application.

This lumps the "user" and the "player", which I would like to avoid.

> So I suppose you can wrap your avatars object just like
> this before sending them, "OR" you can make you own
> implementation of "an avatar" (implementing IPerspective
> interface) and make it IJellyable at first place.

That's interesting. Thanks.



More information about the Twisted-Python mailing list