[Twisted-Python] Throwing exceptions to the client

Cory Dodt corydodt at yahoo.com
Fri Jan 25 01:31:27 MST 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 
    perspective.createUsers(['cdodt'])

1) 

At the server, perpsective method calls 
    self.assertPermission("create_users")
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?

2)

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.

Thanks,

C



__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com




More information about the Twisted-Python mailing list