[Twisted-Python] Throwing exceptions to the client

Cory Dodt corydodt at yahoo.com
Fri Jan 25 03:31:27 EST 2002

Still working on my ACL problem.  

Use case: client connects, calls a perspective_method which is not in its
ACL.  In my test client, I call 


At the server, perpsective method calls 
This assertion fails, so assertPermission throws PermissionDenied.

When this happens, client gets a string with the traceback.  This looked
cool at first, until I tried to handle the error with my failure callback.
 In order to differentiate between PermissionDenied and, for example,
UserAlreadyExists errors, I would have to parse what I get back from the
server.  Parsing strings to find out what happened puts us back at the
protocol layer, and is something my code shouldn't have to do.

MUCH nicer would be if the server tossed the real exception to the client,
not a string.  Referenceable, perhaps.  Is it possible to make this happen
when an exception gets raised?


Another workable solution would be for the perspective_method to return an
exception instead of throwing it.

radix clued me in on Referenceables, so I'm working on making my exception
Referencable.  That's when I noticed that the example code is missing
Referenceables.  Ref'ables and Copyables seem to be fairly intrinsic to
pb, so they should probably show up in the examples somewhere.



Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 

More information about the Twisted-Python mailing list