[mod_python] import error

Simon Bierbaum bierbaum at vierfalt.com
Thu Aug 28 11:52:07 EDT 2008


Does renaming your xml.py (and changing httpd.conf accordingly) to  
anything but 'xml.py' help?

Just a wild guess: apache.import_module first tries to load the  
modules named 'xml', looking for it at sys.path, which happens to  
include /home/becker/framework_python_web. It finds your handler  
script (named xml.py), thinks it's the 'xml' module, reads it,  
stumbles upon the very same import statement it's currently  
executing, and promptly dies and report an import cycle.

Simon

Am 28.08.2008 um 16:48 schrieb Tiago Becker:

> Hello guys!
>
> I'm new to the mod python and im trying to write a few apps but  
> without luck so far...
>
> Im trying to import the module ElementTree, as follow:
>
> import xml.etree.ElementTree as ET
>
> and i also tried:
>
> ET = apache.import_module('xml.etree.ElementTree')
>
> both result in the error
>
> MOD_PYTHON ERROR
>
> ProcessId: 3505
> Interpreter: 'python.dev.com'
>
> ServerName: 'python.dev.com'
> DocumentRoot: '/home/becker/framework_python_web'
>
> URI: '/xml.py'
> Location: None
> Directory: '/'
> Filename: '/home/becker/framework_python_web/xml.py'
> PathInfo: ''
>
> Phase: 'PythonHandler'
> Handler: 'mod_python.publisher'
>
> Traceback (most recent call last):
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 1537, in HandlerDispatch
> default=default_handler, arg=req, silent=hlist.silent)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 1229, in _process_target
> result = _execute_target(config, req, object, arg)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 1128, in _execute_target
> result = object(arg)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> publisher.py", line 204, in handler
> module = page_cache[req]
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 1059, in __getitem__
> return import_module(req.filename)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 296, in import_module
> log, import_path)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 680, in import_module
> execfile(file, module.__dict__)
>
> File "/home/becker/framework_python_web/xml.py", line 9, in <module>
> ET = apache.import_module('xml.etree.ElementTree', autoreload=1,  
> log=0, path=sys.path)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 304, in import_module
> return __import__(module_name, {}, {}, ['*'])
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 991, in load_module
> return _global_modules_cache.import_module(self.__file)
>
> File "/usr/local/lib/python2.5/site-packages/mod_python/ 
> importer.py", line 488, in import_module
> assert(file != parent_info.file), "Import cycle in %s." % file
>
> AssertionError: Import cycle in /home/becker/framework_python_web/ 
> xml.py.
>
>
> MODULE CACHE DETAILS
>
> Accessed: Thu Aug 28 11:13:37 2008
> Generation: 0
>
> _mp_2aae0703a63ecf6c62424b7b7e18a76f {
> FileName: '/home/becker/framework_python_web/xml.py'
> Instance: 1 [IMPORT]
> Generation: 0 [ERROR]
> Modified: Thu Aug 28 11:13:32 2008
> }
>
>
>
> can somebody tell me what am i doing wrong?
>
> Thanks a lot for your answers.
>
> Tiago Becker
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list