[mod_python] Permissions issue

Clodoaldo clodoaldo.pinto.neto at gmail.com
Mon Feb 18 08:12:48 EST 2008


2008/2/18, Hagop Narsesian <hagopnarsesian at yahoo.com>:
> Dear all,
> I have a problem I can't seem to get my head around, I'm hoping this is
> common enough for someone to have a standard reply! I have a
> Python-Pygresql-Postgresql-Apache-Mod_python setup and have
>  aproblem connecting to the postgresql database. I believe this is a
> mod_python issue specifically because the same code works fine as pure
> Python code accessing Postgresql through Pygresql.
>
> There is a shopping basket on a pure html page which sends form data to a
> mod_python coded page and the following error message is received with
> apache's debug feature on. This identical code worked on a windows system,
> and the same connection code works fine as a pure Python module on the said
> machine. In httpd.conf, the user is Apache and the group is Apache.
>
> I've tried every experiment I can think of. Can anyone help?
> Hagop
>
> MOD_PYTHON ERROR
>
> ProcessId:      891
> Interpreter:    '127.0.0.1'
>
> ServerName:     '127.0.0.1'
> DocumentRoot:   '/var/www/html'
>
> URI:            '/csp2/cart.py/p1'
> Location:       None
> Directory:      None
> Filename:       '/var/www/html/csp2/cart.py'
> PathInfo:       '/p1'
>
> Phase:          'PythonHandler'
> Handler:        'mod_python.publisher'
>
> Traceback (most recent call last):
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/importer.py",
> line 1537, in HandlerDispatch
>     default=default_handler, arg=req, silent=hlist.silent)
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/importer.py",
> line 1229, in _process_target
>     result = _execute_target(config, req, object, arg)
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/importer.py",
> line 1128, in _execute_target
>     result = object(arg)
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/publisher.py",
> line 204, in handler
>     module = page_cache[req]
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/importer.py",
> line 1059, in __getitem__
>     return import_module(req.filename)
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/importer.py",
> line 296, in import_module
>     log, import_path)
>
>   File
> "/usr/lib/python2.5/site-packages/mod_python/importer.py",
> line 680, in import_module
>     execfile(file, module.__dict__)
>
>   File "/var/www/html/csp2/cart.py", line 3, in <module>
>     rs=rsw.rsc()
>
>   File "/var/www/html/csp2/rsw.py", line 7, in __init__
>
> self.db=pg.connect(dbname='postgres',user='a_super_user',passwd='a_password',host='localhost',port=5432)
>
> InternalError: could not connect to server: Permission denied
>  Is the server running on host "localhost" and accepting
>  TCP/IP connections on port 5432?
>
>
>
> MODULE CACHE DETAILS
>
> Accessed:       Mon Feb 18 12:04:11 2008
> Generation:     0
>
> _mp_85c706a52797631fd526e880ea631520 {
>   FileName:     '/var/www/html/csp2/cart.py'
>   Instance:     1 [IMPORT]
>   Generation:   0 [ERROR]
>   Modified:     Sat Aug  4 18:34:30 2007
>   Children:     '/var/www/html/csp2/rsw.py',
>                 '/var/www/html/csp2/web_templates.py'
> }
>
> _mp_040d2e7b309cbc54463a95573b512c94 {
>   FileName:     '/var/www/html/csp2/rsw.py'
>   Instance:     1 [IMPORT]
>   Generation:   2
>   Modified:     Thu Feb 14 15:32:52 2008
>   Imported:     Mon Feb 18 12:04:11 2008
> }
>
> _mp_7893a0b888652c1d2565a1ac1016c7e4 {
>   FileName:     '/var/www/html/csp2/web_templates.py'
>   Instance:     1 [IMPORT]
>   Generation:   1
>   Modified:     Sat Aug  4 21:15:48 2007
>   Imported:     Mon Feb 18 12:04:11 2008

Do you have a line starting with 'host' (tcp-ip) in addition to the
line starting with 'local' (unix socket) in the pg_hba.conf file for
that user?

How is your listen_addresses parameter in postgresql.conf configured?

Regards, Clodoaldo Pinto Neto


More information about the Mod_python mailing list