durusmail: quixote-users: Fix for ihooks.py breakage in Python 2.6
Fix for ihooks.py breakage in Python 2.6
2009-06-07
2009-06-12
2009-06-15
Fix for ihooks.py breakage in Python 2.6
Ian Forbes
2009-06-12
Hi Neil

Thanks for looking at this. Sorry it has taken me a few days to get
around to testing it, but things have been a little busy.

Neil Schemenauer wrote:
> It looks like this bug has bitten a few people. Sorry for that. In a
> perfect world, whoever implemented absolute imports should have
> fixed the ihooks module as well. Oh well.
>
> I think I've managed to fix it. I've posted a patch on the issue
> tracker: . If some people could
> test and provide feedback it would probably help ensure this gets
> fixed in Python 2.7.
>
> For those who want to use Python 2.6, a quick solution would be to
> drop the updated ihooks module in the quixote/ptl directory.  You
> can download it from: .

However this the new ihooks.py does not quite seem to fix the problem.

I have included a trace dump below, this might show what is going on.

Firstly, I could run this under Python 2.5 (from Ubuntu jaunty) with a
locally installed copy of Quixote 2.6.

I re-ran the quixote setup.py to install a copy of it under Python 2.6,
then copied in your patched version of ihooks.py into quixote/ptl/ as
per the above. (I also uninstalled Python 2.5 and the version of Quixote
compiled for Python 2.5 just to be sure ...)

But from my application I get this dump. (Actually I made a copy of the
application and edited out a lot of non-essential stuff to try get a
cleaner dump):

My program uses twisted as an http server. I have a root.plt file with
the line "from mx import DateTime".

Note, if I start python2.6 from the command line and enter "from mx
import DateTime" I don't get any errors.


Thanks


Ian




ian@ian2:/usr/local/lib/python2.6/dist-packages/ihooks_test$
../zsduser-test

/usr/local/lib/python2.6/dist-packages/quixote/server/twisted_server.py:6:
DeprecationWarning: twisted.protocols.http has moved to
twisted.web.http. See http://twistedmatrix.com/projects/web.


  from twisted.protocols import http

*** You don't have the (right) mxDateTime binaries installed !

Traceback (most recent call last):

  File
"/usr/local/lib/python2.6/dist-packages/quixote/server/twisted_server.py",
line 143, in 
    main(run)

  File "/usr/local/lib/python2.6/dist-packages/quixote/server/util.py",
line 29, in main
    run(import_object(options.factory), host=options.host,
port=options.port)

  File
"/usr/local/lib/python2.6/dist-packages/quixote/server/twisted_server.py",
line 135, in run
    publisher = create_publisher()
  File "/usr/local/lib/python2.6/dist-packages/ihooks_test/__init__.py",
line 12, in create_publisher
    import root
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
116, in find_import_module
    return self.loader.load_module(fullname, stuff)
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
96, in load_module
    return _load_ptl(name, filename, file)
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
76, in _load_ptl
    return _exec_module_code(code, name, filename)
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
28, in _exec_module_code
    exec code in mod.__dict__
  File "/usr/local/lib/python2.6/dist-packages/ihooks_test/root.ptl",
line 11, in 
    from mx import DateTime
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
116, in find_import_module
    return self.loader.load_module(fullname, stuff)
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
100, in load_module
    return ihooks.ModuleLoader.load_module(self, name, stuff)
  File "/usr/local/lib/python2.6/dist-packages/quixote/ptl/ihooks.py",
line 276, in load_module
    m = self.hooks.load_package(name, filename, file)
  File "/usr/local/lib/python2.6/dist-packages/quixote/ptl/ihooks.py",
line 176, in load_package
    return imp.load_module(name, file, filename, ("", "", PKG_DIRECTORY))
  File "/usr/lib/python2.6/dist-packages/mx/DateTime/__init__.py", line
8, in 
    from DateTime import *
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
116, in find_import_module
    return self.loader.load_module(fullname, stuff)
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
100, in load_module
    return ihooks.ModuleLoader.load_module(self, name, stuff)
  File "/usr/local/lib/python2.6/dist-packages/quixote/ptl/ihooks.py",
line 272, in load_module
    m = self.hooks.load_source(name, filename, file)
  File "/usr/local/lib/python2.6/dist-packages/quixote/ptl/ihooks.py",
line 170, in load_source
    return imp.load_source(name, filename, file)
  File "/usr/lib/python2.6/dist-packages/mx/DateTime/DateTime.py", line
9, in 
    from mxDateTime import *
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
116, in find_import_module
    return self.loader.load_module(fullname, stuff)
  File
"/usr/local/lib/python2.6/dist-packages/quixote/ptl/ptl_import.py", line
100, in load_module
    return ihooks.ModuleLoader.load_module(self, name, stuff)
  File "/usr/local/lib/python2.6/dist-packages/quixote/ptl/ihooks.py",
line 276, in load_module
    m = self.hooks.load_package(name, filename, file)
  File "/usr/local/lib/python2.6/dist-packages/quixote/ptl/ihooks.py",
line 176, in load_package
    return imp.load_module(name, file, filename, ("", "", PKG_DIRECTORY))
  File
"/usr/lib/python2.6/dist-packages/mx/DateTime/mxDateTime/__init__.py",
line 13, in 
    raise ImportError, why
ImportError: initialization of module mxDateTime failed (:import_module() takes at most 4 arguments (5 given))

reply