--- ../../exe0.3/exe/webui/jelly.orig.py 2005-04-12 12:27:58.347586248 +1200 +++ /usr/lib/python2.3/site-packages/twisted/spread/jelly.py 2005-04-12 13:27:36.427635400 +1200 @@ -140,6 +140,20 @@ unjellyableRegistry = {} unjellyableFactoryRegistry = {} +def _newInstance(cls, dct={}): + """Make a new instance of a class + without calling its __init__ method. + dct will be used to update inst.__dict__ + Supports new and old classes + """ + if not isinstance(cls, types.ClassType): + inst = cls.__new__(cls) + inst.__dict__.update(dct) # Copy 'instance' behaviour + else: + inst = instance(cls, dct) + return inst + + def _maybeClass(classnamep): try: object @@ -560,12 +574,12 @@ if not self.taster.isClassAllowed(clz): raise InsecureJelly("Class %s not allowed." % jelType) if hasattr(clz, "__setstate__"): - ret = instance(clz, {}) + ret = _newInstance(clz, {}) state = self.unjelly(obj[1]) ret.__setstate__(state) else: state = self.unjelly(obj[1]) - ret = instance(clz, state) + ret = _newInstance(clz, state) if hasattr(clz, 'postUnjelly'): self.postCallbacks.append(ret.postUnjelly) return ret @@ -697,12 +711,12 @@ if type(clz) is not types.ClassType: raise InsecureJelly("Instance found with non-class class.") if hasattr(clz, "__setstate__"): - inst = instance(clz, {}) + inst = _newInstance(clz, {}) state = self.unjelly(rest[1]) inst.__setstate__(state) else: state = self.unjelly(rest[1]) - inst = instance(clz, state) + inst = _newInstance(clz, state) if hasattr(clz, 'postUnjelly'): self.postCallbacks.append(inst.postUnjelly) return inst