[Twisted-Python] importing twisted modules from my source tree

Ricardo Niederberger Cabral nieder at mail.ru
Thu Oct 23 16:59:10 MDT 2003


(talking about Twisted 1.0.8alpha3)

I'd like to ship my application source code with some twisted modules
(mostly spread.pb and dependencies), but i'm facing some strange
problems, which i guess are due to some magic done on files like
twisted/internet/reactor.py:

del sys.modules['twisted.internet.reactor']

Anyway, I placed the entire twisted dir inside my 'net' package, so
other modules can import twisted from there. (later, i'd remove
twisted modules i don't need). 

Since some twisted modules import other twisted modules out of it's
package, i had to hardcode something like 

sys.path.append('/home/rnc/prj/imgseek-net/isnLib/net/') 

before any twisted related stuff is imported.

But i get the following error when running my app (which eventually imports
imgClient, who by it's turn eventually imports reactor from twisted.internet):

Traceback (most recent call last):
  File "./isnLib/net/imgClient.py", line 68, in connect
    reactor.connectTCP(self.addr, self.port, factory)
AttributeError: 'module' object has no attribute 'connectTCP'

I've noticed that if I run "python isnLib/net/imgClient.py" on a
command line, reactor is imported correctly (and then becomes a bound
method of twisted.internet.default.SelectReactor).

(If necessary, my code is at
http://cvs.sf.net/viewcvs.py/imgseek/imgseek-net2/isnLib/net/#dirlist)

One solution would be asking the user to install the full Twisted
package, but i really don't want that as I don't need things like
Woven, Lore, etc.

Any ideas ?

Best regards,
-- 
rnc <nieder|at|mail.ru>




More information about the Twisted-Python mailing list