On Nov 22, 2013, at 12:01 PM, Daniel Sank <[email protected]> wrote:
> Thanks much for the reply.
>
>> So, this strikes me as incredibly subtle, and likely a bug
>
> Should I file a ticket?
Absolutely.
>> One way to fix this is to manually construct a ViewPoint rather than a
>> Viewable and pass that to the client.
>
> If someone would be willing to supply a very simple demonstration of
> this I would appreciate it very much.
It's a very simple change to your server; your client remains the same. Just
construct a ViewPoint with the user as perspective around your viewable.
#!/usr/bin/env python
from zope.interface import implements
from twisted.cred import portal, checkers
from twisted.spread import pb
from twisted.internet import reactor
class MyViewable(pb.Viewable):
def view_test(self, perspective, description):
print("This viewpoint was %s the Avatar" % description)
print("and we got the following perspective: %s" % perspective)
class MyRealm(object):
implements(portal.IRealm)
def requestAvatar(self, avatarID, mind, *interfaces):
assert pb.IPerspective in interfaces
avatar = User(avatarID, mind)
return pb.IPerspective, avatar, lambda a=avatar: a.logout()
class User(pb.Avatar):
def __init__(self, name, mind):
self.name = name
self.mind = mind
self.v = MyViewable()
mind.callRemote("takeViewable", pb.ViewPoint(self, self.v))
def perspective_getViewable(self):
return self.v
def logout(self):
self.mind = None
realm = MyRealm()
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("alice", "1234")
p = portal.Portal(realm, [checker])
reactor.listenTCP(8800, pb.PBServerFactory(p))
reactor.run()
>> But I do think that we should find a way to make your use-case work, to, or
>> at the very
>> least document the reasons why it doesn't in a comprehensible way...
>
> I am willing to help but as of right now I only know how to use
> perspective broker; I do not know how it works under the hood.
Well, it's open source, so the hood opens right up, go ahead and pop it :-).
> I have been collecting notes on bugs in the perspective broker
> documentation. I promise to submit a documentation patch when I have a
> first draft of my project up and running.
Please feel free to submit _many_ bugs, if there are many issues :-).
-glyph
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python