[Twisted-Python] Allowing a type to be transmitted by jelly?
This is one of those problems where I've got a solution, but it *seems*
like it should be something that can be done that's a little less
drastic. Here's the problem:
Want to expose a simple data-type (in this case a sub-class of
tuple, the PySNMP OID object) to allow for transmission across pb
queries and returns.
Now, I've tried quite a number of iterations on this, from:
jelly.globalSecurity.allowInstancesOf(
oid.OID,
)
through using classes like this:
class PBTypeAllowingServerFactory( pb.PBServerFactory ):
"""Allow various types to be transported"""
def buildProtocol(self, addr):
"""Return a Broker attached to me (as the service provider).
"""
broker = pb.PBServerFactory.buildProtocol( self, addr )
broker.security.allowInstancesOf(
oid.OID,
)
return broker
class PBTypeAllowingClientFactory( pb.PBClientFactory ):
def clientConnectionMade(self, broker):
"""Expand the types allowed to be communicated"""
broker.security.allowInstancesOf(
oid.OID,
)
return pb.PBClientFactory.clientConnectionMade( self, broker )
but whenever I try using jelly for the encoding it complains that:
Traceback (most recent call last):
File "/home/mcfletch/pylive/Twisted/twisted/internet/defer.py",
line 190, in addCallbacks
self._runCallbacks()
File "/home/mcfletch/pylive/Twisted/twisted/internet/defer.py",
line 358, in _runCallbacks
self.result = callback(self.result, *args, **kw)
File
"/home/mcfletch/pylive/cinemon/cinespread/metaperspective.py", line
216, in callWhenFree
return perspective.callRemote( *args, **named ).addErrback(
File "/home/mcfletch/pylive/Twisted/twisted/spread/pb.py", line
382, in callRemote
_name, args, kw)
--- <exception caught here> ---
File "/home/mcfletch/pylive/Twisted/twisted/spread/pb.py", line
857, in _sendMessage
netArgs = self.serialize(args, perspective=perspective,
method=message)
File "/home/mcfletch/pylive/Twisted/twisted/spread/pb.py", line
811, in serialize
return jelly(object, self.security, None, self)
File "/home/mcfletch/pylive/Twisted/twisted/spread/jelly.py", line
896, in jelly
return _Jellier(taster, persistentStore, invoker).jelly(object)
File "/home/mcfletch/pylive/Twisted/twisted/spread/jelly.py", line
480, in jelly
sxp.append(self.jelly(item))
File "/home/mcfletch/pylive/Twisted/twisted/spread/jelly.py", line
476, in jelly
sxp.append(self.jelly(item))
File "/home/mcfletch/pylive/Twisted/twisted/spread/jelly.py", line
511, in jelly
raise InsecureJelly("Type not allowed for object: %s %s" %
twisted.spread.jelly.InsecureJelly: Type not allowed for object:
participants (5)
-
Itamar Shtull-Trauring
-
Johann Borck
-
Micky Latowicki
-
Mike C. Fletcher
-
Mike C. Fletcher