[Twisted-Python] Re: More on PB Copyable Errors

Justin Johnson justinjohnson at gmail.com
Wed Dec 29 07:56:48 MST 2004


Attached is a patch with modifications to pb.py and jelly.py.  With
the patch applied, CopyableFailure.getStateToCopy first checks to see
if the actual exception instance's class has an unjellyable registered
so it can be unjellied on the other side.  If it does, the actual
exception instance is passed back as failure.value.  Otherwise a
string representation is passed back as it is today.

I'd like some confirmation that this is an acceptable approach.  If so
I will gladly submit an enhancement and attach the patch.

-Justin


On Tue, 28 Dec 2004 14:34:02 -0600, Justin Johnson
<justinjohnson at gmail.com> wrote:
> Whoops... forgot the attachments.  Here they are.
> 
> 
> On Tue, 28 Dec 2004 14:32:04 -0600, Justin Johnson
> <justinjohnson at gmail.com> wrote:
> > I would really like to be able to pass custom exceptions over the wire
> > in PB.  Previous discussion on this list ended with the conclusion
> > that it currently isn't possible without hacking a local copy of
> > Twisted.
> >
> > I have done that to get the result I want, with minimal testing, and
> > would like to get some discussion going around this topic.  Attached
> > are 3 test files, s.py for the server, c.py for the client, and e.py
> > for the error definitions which are imported by both s.py and c.py.
> > If I make the following modification to my local copy of
> > twisted/spread/pb.py in the CopyableFailure's getStateToCopy method,
> > the custom error is passed back as I want.
> >
> >   #state['value'] = str(self.value) # Exception instance
> >   state['value'] = self.value # Exception instance
> >
> > I was wondering if there is a reason we wouldn't want to change the
> > code to check for registered unjellyables for the exception, and
> > return them (or rather go through the jelly/unjelly process) if they
> > exist, but return the string representation otherwise.  Maybe that is
> > more complicated than I realize.
> >
> > Any thoughts or suggestions on how we might make this possible?
> > Thanks.
> > -Justin
> >
> 
> 
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: </pipermail/twisted-python/attachments/20041229/0184d235/attachment-0002.txt>


More information about the Twisted-Python mailing list