Re: [Twisted-Python] Do Viewables absolutely have to be return'ed by Avatars?

2013-12-08 Thread Glyph

On Dec 7, 2013, at 9:30 AM, Daniel Sank  wrote:

> Glyph,
> 
> It seems to me that the right way to fix this issue with being able to
> pass Cacheable and Viewable instances as arguments to mind.callRemote
> methods would be to "attach" a perspective to that mind, possibly
> during login (with a means for doing in manually as well).

The mind might be any object, or it might be no object (i.e. None).  This is 
confusingly documented, as remote_loginAnonymous is the only thing that 
explicitly spells it out, but given that it's a remote thing coming from the 
client, and no type-checking is performed, that's implicitly what it is.

> As soon as
> that though crossed my mind I remembered that I've seen "attach" and
> "detach" floating around in the pb documentation as if it were once
> upon a time a real part of the API, but sort of fizzled or was never
> really adopted.

This part of PB was removed many years ago, and references in the documentation 
ought to be removed as well.

> I would appreciate your comment on this to help me
> understand the state of pb and whether my idea of how to proceed is
> correct?

In the case where a 'mind' object has a callRemote method, it's one of two 
things: a RemoteReference or a RemoteCacheObserver.  Both of these have a 
(public, given its name, but not super well documented) "perspective" attribute 
which triggers the serialization behavior you want when calling callRemote.  So 
'attaching' that perspective is as simple of setting the attribute.  In your 
application, I think just setting that attribute is a much better idea than the 
craziness that I was suggesting with a custom Perspectivize class, and perhaps 
actually better than manually constructing a ViewPoint, since it generalizes 
completely to the whole serialization process.

What's slightly more problematic is making this general.  You have to fully 
deserialize the mind object before login, because it's explicitly provided in 
order to allow cred implementations to interact with the client during login.  
And since you don't know what the avatar is before it's time to log in, there's 
no way to deserialize it in this way!

This is important if your Mind object were to be a custom Copyable that 
contained more than one RemoteReference, and, for example, had its own 
callRemote which could dispatch to different ones depending on what it's being 
asked to do.

So how about this:

Introduce a new custom interface, IHaveAPerspective (name intentionally 
terrible so I don't get hung up on naming it well); and then, in _cbLogin, do 
'if IHaveAPerspective.providedBy(mind): mind.perspective = avatar'. (Be sure to 
get the right avatar, of course, the one before it's wrapped in an 
AsReferenceable.)  If someone had a more elaborately constructed mind object 
than a RemoteReference, then they could implement the interface and write a 
property that set it on all the relevant references.

Then, RemoteReference and RemoteCacheObserver can implement this new interface.

For compatibility reasons, you might need to make this behavior disabled by 
default.  But hey, it would be nice to have a public name for _PortalRoot 
rather than relying on adapter magic to construct one, so that new name could 
just do this by default.

-glyph

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Do Viewables absolutely have to be return'ed by Avatars?

2013-12-08 Thread Glyph

On Dec 7, 2013, at 12:28 PM, Daniel Sank  wrote:

> I'm posting this for future hapless n00bs like myself who find this
> thread while trying to grok perspective broker.
> 
>> It seems to me that the right way to fix this issue with being able to
>> pass Cacheable and Viewable instances as arguments to mind.callRemote
>> methods would be to "attach" a perspective to that mind, possibly
>> during login (with a means for doing in manually as well).
> 
> By looking around in the source code and doing more experiments I have
> figured out that you can just do this
> 
> mind.perspective = thePerspectiveIWantToAssociateWithThisMind

Oops, I wrote my previous reply without having seen this message! :-).

And yes, I'd totally forgotten that that's a way to do it, because the 
documentation is horrible and it's been years since I worked on a PB-based 
application.  I would strongly encourage you to contribute documentation 
enhancements that add the requisite level of docstring coverage to PB.

Thanks for your interest so far.

-glyph


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Do Viewables absolutely have to be return'ed by Avatars?

2013-12-08 Thread Daniel Sank
> I would strongly encourage you to contribute documentation enhancements that 
> add the requisite level of docstring coverage to PB.

Eagerly awaiting for the website login to work so I can do that.

> it's been years since I worked on a PB-based application.

I would like to know, is there anyone else who knows how pb works, or
is it mostly just you (glyph)?

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Do Viewables absolutely have to be return'ed by Avatars?

2013-12-08 Thread Daniel Sank
> I would like to know, is there anyone else who knows how pb works,
> or is it mostly just you (glyph)?

I'm asking this just to get a feel for who's who among twisted
developers, not for any other reason. To be clear your help has been
awesome and I really appreciate it very much! :)

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Queries about connecting to a XML-RPC server over IPv6

2013-12-08 Thread Amit Saha
Hello,

I am trying to connect to a local XML-RPC server with IPv4 *disabled*. Here is 
my script:

from twisted.web.xmlrpc import Proxy
from twisted.internet import reactor

def printValue(value):
print repr(value)
reactor.stop()

def printError(error):
print 'error', error
reactor.stop()

proxy = Proxy('http://localhost6:8000')
proxy.callRemote('my_proxy_method').addCallbacks(printValue, printError)


When I run it, i get "No route to host: 101, Network is unreachable".

However, 'curl -6 localhost:8000' succeeds. What could be going on here?
I am using Twisted-12.2 on Fedora 19.

Thanks for any insights.

Best,
Amit.

-- 
Amit Saha 

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Queries about connecting to a XML-RPC server over IPv6

2013-12-08 Thread Amit Saha


- Original Message -
> From: "Amit Saha" 
> To: twisted-python@twistedmatrix.com
> Sent: Monday, December 9, 2013 3:28:47 PM
> Subject: [Twisted-Python] Queries about connecting to a XML-RPC server over   
> IPv6
> 
> Hello,
> 
> I am trying to connect to a local XML-RPC server with IPv4 *disabled*. Here
> is my script:
> 
> from twisted.web.xmlrpc import Proxy
> from twisted.internet import reactor
> 
> def printValue(value):
> print repr(value)
> reactor.stop()
> 
> def printError(error):
> print 'error', error
> reactor.stop()
> 
> proxy = Proxy('http://localhost6:8000')
> proxy.callRemote('my_proxy_method').addCallbacks(printValue, printError)
> 
> 
> When I run it, i get "No route to host: 101, Network is unreachable".
> 
> However, 'curl -6 localhost:8000' succeeds. What could be going on here?
> I am using Twisted-12.2 on Fedora 19.

That should be, 'curl -6 localhost6:8000'.


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python