Dominique.Holzwarth at ch.delarue.com
Dominique.Holzwarth at ch.delarue.com
Tue Mar 25 05:37:46 EDT 2008
Hello everyone I've got some problems with importing modules from packages when using mod_python. Currently I'm using the Publisher Handler which is configured like this: <Directory "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\python"> AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On </Directory> My directory structure looks like this python/ main.py database/ __init__.py common.py (i hope the tabs will be posted correctly...) The main.py looks like this: ********************************* from database import common def index(req): msg = database.common.myCommonVariable return msg ********************************* The common.py just defines a variable: myCommonVariable = "hello" When I do a http://localhost/python/main.py I get the following error: URI: '/python/main.py' Location: None Directory: 'C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/python/' Filename: 'C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\python\\main.py' PathInfo: '' Phase: 'PythonHandler' Handler: 'mod_python.publisher' Traceback (most recent call last): File "C:\Program Files\Python25\Lib\site-packages\mod_python\importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "C:\Program Files\Python25\Lib\site-packages\mod_python\importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "C:\Program Files\Python25\Lib\site-packages\mod_python\importer.py", line 1128, in _execute_target result = object(arg) File "C:\Program Files\Python25\Lib\site-packages\mod_python\publisher.py", line 204, in handler module = page_cache[req] File "C:\Program Files\Python25\Lib\site-packages\mod_python\importer.py", line 1059, in __getitem__ return import_module(req.filename) File "C:\Program Files\Python25\Lib\site-packages\mod_python\importer.py", line 296, in import_module log, import_path) File "C:\Program Files\Python25\Lib\site-packages\mod_python\importer.py", line 680, in import_module execfile(file, module.__dict__) File "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\python\main.py", line 1, in <module> from database import common ImportError: No module named database I've found an old post in the mailing list concerning the same problem and according to that post it should work... Does anyone have an idea what could be wrong? Greetings Dominique ********************************* This e-mail and any files attached are strictly confidential, may be legally privileged and are intended solely for the addressee. If you are not the intended recipient please notify the sender immediately by return email and then delete the e-mail and any attachments immediately. The views and or opinions expressed in this e-mail are not necessarily the views of De La Rue plc or any of its subsidiaries and the De La Rue Group of companies, their directors, officers and employees make no representation about and accept no liability for its accuracy or completeness. You should ensure that you have adequate virus protection as the De La Rue Group of companies do not accept liability for any viruses De La Rue plc Registered No.3834125, De La Rue Holdings plc Registered No 58025 and De La Rue International Limited Registered No 720284 are all registered in England with their registered office at: De La Rue House, Jays Close, Viables, Hampshire RG22 4BS
|