[Twisted-Python] Trouble with pb.CopyableFailure

Justin Johnson justinjohnson at gmail.com
Wed Nov 10 16:36:57 EST 2004


I am trying to get pb.CopyableFailure to work, but am getting
unexpected results.

The following module is imported by both client and server.

---------------------
#!/usr/local/bin/python
"""
errors.py
"""
from twisted.spread import pb, jelly

class Error(pb.Error):
    """Base class for exceptions in this module."""
    pass

class WebViewOnDifferentServer(Error, pb.CopyableFailure, pb.RemoteCopy):
    def __init__(self, viewTag, server):
        Error.__init__(self)
        pb.CopyableFailure.__init__(self)
        self.viewTag = viewTag
        self.server = server
    def __str__(self):
        return "WebViewOnDifferentServer: viewTag=%s, server=%s" %
(self.viewTag, self.server)
---------------------


The client and server both contain the following 2 lines of code.

from ratcontrol import errors
pb.setUnjellyableForClass(errors.WebViewOnDifferentServer,
errors.WebViewOnDifferentServer)


The server raises an exception as follows.
----------------
if view.serverHost != config.thisServer:
                    ## We can't remove web views unless we're local,
since they don't
                    ## have a global path.
                    log.msg("Web view '%s' cannot be removed because
it isn't on this server." % tag)
                    raise errors.WebViewOnDifferentServer(view.tag,
view.serverHost)
-----------------

The server displays the following to the log.

2004/11/10 15:54 Eastern Standard Time [Broker,0,10.113.53.10] User
justin logged in

2004/11/10 15:54 Eastern Standard Time [Broker,0,10.113.53.10]
rmview(testview1, False)
2004/11/10 15:54 Eastern Standard Time [-] Web view 'testview1' cann
ot be removed because it isn't on this server.
2004/11/10 15:54 Eastern Standard Time [-] Peer will receive following
PB traceback:
2004/11/10 15:54 Eastern Standard Time [-] Failure: None: None


The failure that the client gets is None.

Does anyone know what I'm doing wrong here?  I've searched through the
docs but don't see specific examples of how to use CopyableFailure, so
I made the assumption that I could raise a CopyableFailure instead of
specifically writing code to send the failure back to the client.  Any
help is appreciated.

Thanks.
-Justin




More information about the Twisted-Python mailing list