[Paolo Comitini <pcm@mixadlive.com>] Fwd: [Zope] Postgres permissions with psycopyg

Federico Di Gregorio fog@mixadlive.com
19 Jun 2001 15:02:53 +0200


---------------------------------------------------------------
I´m using Zope 2.3.2, PostgreSQL 7.1.2 and psycopg 0.99.2.

Opening a database connection works well.  I used the connection string:

    dbname=web

Unfortunately if I want to test the connection using

    select * from testtable ;

I get

Error Type: ProgrammingError
Error Value: ERROR: mitarbeiter: Permission denied. select * from testtable ;


Looking at /var/log/postgres.log I see the following entries:

2001-06-19 14:05:24 [22300]  DEBUG:  connection: host=[local] user=www-data
 database=web 2001-06-19 14:05:43 [22300]  ERROR:  testtable: Permission
 denied.

where www-data is the user which runs apache and zope on a Debian system.
I made sure in psql:

   web=# grant all on testtable to "web-data" ;
   CHANGE
-------------------------------------------------------------------------

if you gave to zope a connection string like:

    dbname=web user=www-data

try to do:

    dbname=web user="www-data"


if i remember correctly postgresql has problems with www-data without
quotes around the name. this is clearly a psycopg (not zpsycopgda)
problem, so try to debug it from python running interactively the
follwing code:

    import psycopg
    o = psycopg.connect('dbname=web user="www-data"') # note quotes
    c = o.cursor()
    c.execute('select * from testtable')

hope this helps,
federico

-- 
Federico Di Gregorio
MIXAD LIVE Chief of Research & Technology              fog@mixadlive.com
Debian GNU/Linux Developer & Italian Press Contact        fog@debian.org
  The devil speaks truth much oftener than he's deemed.
                                   He has an ignorant audience. -- Byron