[Twisted-Python] Unjellying per broker vs. global jelly.unjellyableRegistry
![](https://secure.gravatar.com/avatar/0cdda6a2fc76a3fabb29f0e8056ebdd6.jpg?s=120&d=mm&r=g)
Hi, I have attached a patch, which makes it possible to unjelly different classes depending on the broker they were sent through (basically one can set a brokers 'unjellyableRegistry' attribute, which then get's used instead of the global one). Has such a feature already been planned? Any chance of getting it included? - Ralf =================================================================== RCS file: /cvs/Twisted/twisted/spread/jelly.py,v retrieving revision 1.48 diff -u -u -r1.48 jelly.py --- twisted/spread/jelly.py 4 Jun 2003 00:18:03 -0000 1.48 +++ twisted/spread/jelly.py 24 Dec 2003 01:36:31 -0000 @@ -495,13 +495,22 @@ class _Unjellier: - def __init__(self, taster, persistentLoad, invoker): + unjellyableRegistry = unjellyableRegistry + unjellyableFactoryRegistry = unjellyableFactoryRegistry + + def __init__(self, taster, persistentLoad, invoker, + unjellyableRegistry=None, unjellyableFactoryRegistry=None): self.taster = taster self.persistentLoad = persistentLoad self.references = {} self.postCallbacks = [] self.invoker = invoker + if unjellyableRegistry is not None: + self.unjellyableRegistry = unjellyableRegistry + if unjellyableFactoryRegistry is not None: + self.unjellyableFactoryRegistry = unjellyableFactoryRegistry + def unjellyFull(self, obj): o = self.unjelly(obj) for m in self.postCallbacks: @@ -514,7 +523,7 @@ jelType = obj[0] if not self.taster.isTypeAllowed(jelType): raise InsecureJelly(jelType) - regClass = unjellyableRegistry.get(jelType) + regClass = self.unjellyableRegistry.get(jelType) if regClass is not None: if isinstance(regClass, ClassType): inst = _Dummy() # XXX chomp, chomp @@ -526,7 +535,7 @@ if hasattr(val, 'postUnjelly'): self.postCallbacks.append(inst.postUnjelly) return val - regFactory = unjellyableFactoryRegistry.get(jelType) + regFactory = self.unjellyableFactoryRegistry.get(jelType) if regFactory is not None: state = self.unjelly(obj[1]) inst = regFactory(state) @@ -845,7 +854,9 @@ return _Jellier(taster, persistentStore, invoker).jelly(object) -def unjelly(sexp, taster = DummySecurityOptions(), persistentLoad=None, invoker=None): +def unjelly(sexp, taster = DummySecurityOptions(), persistentLoad=None, invoker=None, + unjellyableRegistry=None, unjellyableFactoryRegistry=None): + """Unserialize from s-expression. Takes an list that was the result from a call to jelly() and unserializes @@ -853,4 +864,4 @@ of SecurityOptions, will cause an InsecureJelly exception to be raised if a disallowed type, module, or class attempted to unserialize. """ - return _Unjellier(taster, persistentLoad, invoker).unjellyFull(sexp) + return _Unjellier(taster, persistentLoad, invoker, unjellyableRegistry, unjellyableFactoryRegistry).unjellyFull(sexp) Index: twisted/spread/pb.py =================================================================== RCS file: /cvs/Twisted/twisted/spread/pb.py,v retrieving revision 1.154 diff -u -u -r1.154 pb.py --- twisted/spread/pb.py 17 Oct 2003 19:06:23 -0000 1.154 +++ twisted/spread/pb.py 24 Dec 2003 01:36:33 -0000 @@ -500,6 +500,8 @@ version = 6 username = None factory = None + unjellyableRegistry = None + unjellyableFactoryRegistry = None def __init__(self, isClient=1, security=globalSecurity): banana.Banana.__init__(self, isClient) @@ -826,7 +828,7 @@ self.unserializingPerspective = perspective try: - return unjelly(sexp, self.security, None, self) + return unjelly(sexp, self.security, None, self, self.unjellyableRegistry, self.unjellyableFactoryRegistry) finally: self.unserializingPerspective = None -- brainbot technologies ag boppstrasse 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:ralf@brainbot.com
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Tue, 2003-12-23 at 20:59, Ralf Schmitt wrote:
Thanks! Add this to the bug tracker (twistedmatrix.com/bugs/) and nosy me and warner. As always, note that patches to Twisted need to be given copyright to glyph (who is sole owner of Twisted). This does not affect your own use of code you wrote. -- Itamar Shtull-Trauring http://itamarst.org Looking for a job: http://itamarst.org/resume.html
![](https://secure.gravatar.com/avatar/0cdda6a2fc76a3fabb29f0e8056ebdd6.jpg?s=120&d=mm&r=g)
Itamar Shtull-Trauring <itamar@itamarst.org> writes:
Issue 452. But how do I change the nosy list after creating an issue?
ok, copyright assigned to glyph. or do you need written permission? - ralf -- brainbot technologies ag boppstrasse 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:ralf@brainbot.com
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Sun, 2003-12-28 at 17:29, Ralf Schmitt wrote:
ok, copyright assigned to glyph. or do you need written permission?
That'll do. Unless you're a SCO employee. -- Itamar Shtull-Trauring http://itamarst.org Looking for a job: http://itamarst.org/resume.html
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Tue, 2003-12-23 at 20:59, Ralf Schmitt wrote:
Thanks! Add this to the bug tracker (twistedmatrix.com/bugs/) and nosy me and warner. As always, note that patches to Twisted need to be given copyright to glyph (who is sole owner of Twisted). This does not affect your own use of code you wrote. -- Itamar Shtull-Trauring http://itamarst.org Looking for a job: http://itamarst.org/resume.html
![](https://secure.gravatar.com/avatar/0cdda6a2fc76a3fabb29f0e8056ebdd6.jpg?s=120&d=mm&r=g)
Itamar Shtull-Trauring <itamar@itamarst.org> writes:
Issue 452. But how do I change the nosy list after creating an issue?
ok, copyright assigned to glyph. or do you need written permission? - ralf -- brainbot technologies ag boppstrasse 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:ralf@brainbot.com
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Sun, 2003-12-28 at 17:29, Ralf Schmitt wrote:
ok, copyright assigned to glyph. or do you need written permission?
That'll do. Unless you're a SCO employee. -- Itamar Shtull-Trauring http://itamarst.org Looking for a job: http://itamarst.org/resume.html
participants (2)
-
Itamar Shtull-Trauring
-
Ralf Schmitt