[mod_python] python path and 3.3

Clodoaldo clodoaldo.pinto.neto at gmail.com
Fri Dec 1 18:44:52 EST 2006


2006/12/1, Graham Dumpleton <grahamd at dscpl.com.au>:
>
> >
> > URI:            '/'
> > Location:       None
> > Directory:      None
>
> The '~/' prefix will be replaced with the value of 'Directory' as
> shown here, but it
> isn't set because you have the PythonHandler directive outside of any
> Directory
> directive or .htaccess file. Thus, it can't know what the handler
> root is. Using:
>
>     DocumentRoot /var/www/html/carconsumption.com
>     <Directory /var/www/html/carconsumption.com>
>     SetHandler mod_python
>     PythonHandler mod_python.publisher
>     PythonDebug On
>     PythonOption mod_python.importer.path "['~/mod']"
>     </Directory>
>

Ok, I did it and now this works:

import constants as C

But this does not work:

from mod_python import apache
C = apache.import_module('constants.py')

MOD_PYTHON ERROR

ProcessId:      28816
Interpreter:    'carconsumption.s0'

URI:            '/'
Location:       None
Directory:      None
Filename:       '/var/www/html/carconsumption.com/index.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'mod_python.publisher'

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
1522, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
1227, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
1126, in _execute_target
    result = object(arg)

  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py",
line 204, in handler
    module = page_cache[req]

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
1057, in __getitem__
    return import_module(req.filename)

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
294, in import_module
    log, import_path)

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
678, in import_module
    execfile(file, module.__dict__)

  File "/var/www/html/carconsumption.com/index.py", line 4, in ?
    C = apache.import_module('constants.py')

  File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line
302, in import_module
    return __import__(module_name, {}, {}, ['*'])

ImportError: No module named py


MODULE CACHE DETAILS

Accessed:       Fri Dec  1 23:42:04 2006
Generation:     0

_mp_96eec165c095033cec4187d8d6982912 {
  FileName:     '/var/www/html/carconsumption.com/index.py'
  Instance:     1 [IMPORT]
  Generation:   0 [ERROR]
  Modified:     Fri Dec  1 23:36:42 2006
  Children:     '/var/www/html/carconsumption.com/mod/constants.py'
}

_mp_a27b25a9c8e4a572b9b17e5189dec319 {
  FileName:     '/var/www/html/carconsumption.com/mod/constants.py'
  Instance:     1 [IMPORT]
  Generation:   1
  Modified:     Wed Nov 29 17:42:30 2006
  Imported:     Fri Dec  1 23:42:04 2006
}


Regards,
-- 
Clodoaldo Pinto Neto


More information about the Mod_python mailing list