[Twisted-Python] different import paths lead to insecureJelly

Daniel Sank sank.daniel at gmail.com
Thu Jan 2 00:54:43 MST 2014


I have a project in which various modules need to import a particular
module "util" which has the following content:

    # util.py
    class FooMaster(pb.Cacheable):
        ...

    class FooSlave(pb.RemoteCache):
        ...

    pb.setUnjellyableForClass(FooMaster, FooSlave)

Module "server" lives in the same directory as util and imports it like this
    # server.py
    import util

Module clent lives in an entirely different directory and imports util like
this
    # client.py
    import myproject.path.to.some.files.util as util

This leads to the infamous insecureJelly exception because the name of the
FooMaster class winds up being different due to the different import
statements. Specifically, server's copy of pb registers it as

"util.FooMaster"

but client's copy registers it as

"myproject.path.to.some.files.util.FooMaster"

1. Is it a bug that pb cares about how something was imported when
registering unjellyable classes?
2. If not, how am I supposed to work around this?
3. The problem goes away if I use the long, fully qualified import
statement everywhere. Is that what I'm supposed to do?

I read the howto and the on Stackoverflow question I could find regarding
this issue. In both cases, it says to not define names in a main file
precisely to avoid this issue, but not what to do in my case.

Thank you for any advice.

-- 
Daniel Sank
Department of Physics
Broida Hall
University of California
Santa Barbara, CA 93117
(805)893-3899
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140101/c9c53f5f/attachment.html>


More information about the Twisted-Python mailing list