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-15
Neil Schemenauer wrote:

> I don't get any errors using the patched ihooks.py, Python 2.6 and
> the latest mxDateTime module.  I created a test PTL module
> containing "from mx import DateTime" and importing it works okay.
> Could you try creating a .py module containing "from mx import
> DateTime" and see if that works for you?  Maybe ihooks is not the
> problem.

> One other thing to check it where ihooks is coming from,
> e.g.
>
>     >>> from quixote import enable_ptl; enable_ptl()
>     >>> import sys
>     >>> sys.modules['quixote.ptl.ihooks']
>     

I tested this one first:

ian@ian2:~$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from quixote import enable_ptl
/usr/local/lib/python2.6/dist-packages/quixote/http_response.py:7:
DeprecationWarning: the sets module is deprecated
  from sets import Set
>>> enable_ptl()
>>> import sys
>>> sys.modules['quixote.ptl.ihooks']

>>>

So far so good ...


Test one:

I created a module "ihooks_test" with

__init__.py:
from quixote import enable_ptl
from quixote.publish import Publisher
enable_ptl()
def create_publisher():
  import root
  return Publisher(root.RootDirectory())

and a single file

root.ptl:
from mx import DateTime
from quixote.directory import Directory
class RootDirectory(Directory):
  pass

And I called it with this line:
python \
/usr/local/lib/python2.6/dist-packages/quixote/server/twisted_server.py\
 --factory ihooks_test.create_publisher

Result long error dump:

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

Traceback (most recent call last):

 File
"/usr/lib/python2.6/dist-packages/mx/DateTime/mxDateTime/__init__.py",
line 13, in 
    raise ImportError, why


Test two:
Same as above, but renamed root.ptl to root.py. Result, identical error
dump.

Test three:
Deleted the line "enable_ptl()" from __init__.py
Result, it works and starts a publisher process...


The mx.DateTime is the binary one distributed with Ubuntu Jaunty:

ian@ian2:/usr/local/lib/python2.6/dist-packages/ihooks_test$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from mx import DateTime
>>> sys.modules['mx.DateTime']

>>>


I am not sure if this answers the questions. I am just begining to
understand some of the inner workings of python and quixote. But for the
moment with Ubuntu Jaunty it seems best to stick with python2.5 and
install quixote manually from the sources.

Thanks

Ian
reply