Package: python-sqlalchemy
Version: 0.3.10-1
Severity: normal

If, when lazy-loading a parent record (by accessing a child
record's refering attribute), there is a problem looking up
the parent record (eg: don't have permissions in the database),
the lookup fails silently instead of being thrown. I think the
error is being suppressed somewhere.

More info about my setup:
 - I'm using Elixir but this looks like a SQLAlchemy problem
 - My underlying RDBMS is Postgresql 8.1

My exact problem (as refered to above) is that the db user does not have
permission to read the parent table.

I turned on debug-level logging from a testing app, here is some
relevant output:

===== DEBUG OUTPUT STARTS =====

2007-09-17 12:01:27,732 DEBUG
sqlalchemy.orm.attributes.InstrumentedAttribute Executing lazy callable
on [EMAIL PROTECTED]
2007-09-17 12:01:27,733 DEBUG sqlalchemy.orm.strategies.LazyLoader lazy
load attribute client_prod on instance [EMAIL PROTECTED]
2007-09-17 12:01:27,737 INFO sqlalchemy.pool.QueuePool.0x..74 Connection
<connection object at 0xb77234e8; dsn: 'dbname=rrdbsql_sr
host=172.30.166.51 port=5432 user=media-exporter password=xxxxxxxxxxx',
closed: 0> checked out from pool
2007-09-17 12:01:27,742 INFO sqlalchemy.engine.base.Engine.0x..b4 SELECT
tblclient_producttype.lngclient_prod AS
tblclient_producttype_lngclient_prod, tblclient_producttype.strdesc AS
tblclient_producttype_strdesc, tblclient_producttype.strprod_type AS
tblclient_producttype_strprod_type, tblclient_producttype.strprodcode AS
tblclient_producttype_strprodcode, tblclient_producttype.lngclient AS
tblclient_producttype_lngclient
FROM tblclient_producttype
WHERE tblclient_producttype.lngclient_prod =
%(tblclient_producttype_lngclient_prod)s ORDER BY
%tblclient_producttype.lngclient_prod
2007-09-17 12:01:27,745 INFO sqlalchemy.engine.base.Engine.0x..b4
{'tblclient_producttype_lngclient_prod': 451}
2007-09-17 12:01:27,748 INFO sqlalchemy.engine.base.Engine.0x..b4
ROLLBACK
2007-09-17 12:01:27,750 INFO sqlalchemy.pool.QueuePool.0x..74 Connection
<connection object at 0xb77234e8; dsn: 'dbname=rrdbsql_sr
host=172.30.166.51 port=5432 user=media-exporter password=xxxxxxxxxxx',
closed: 0> being returned to pool

===== DEBUG OUTPUT ENDS =====

In the above, the db user (media-exporter) has SELECT permission for
table 'tbltraffic' but no permission for table 'tblclient_producttype'.

Postgresql logs the problem in it's logfile when the above runs:

"ERROR:  permission denied for relation tblclient_producttype"

But there is no exception thrown by sqlalchemy, or any warnings logged.

Also I tested by logging into the database with the exporter user with psql,
and it confirmed that there are insufficient privileges.

Some more background info to give you some context: I'm currently
writing a python script to export some data from one database and
import into another. To this end, I've created new users in the
source and destination database (media-exporter and media-importer,
respectively), who have the minimum amounts of permission on the
minimum # of tables to help protect against accidental db damage.
I'm relying on exceptions thrown by my app (during lazy loading
as I walk through the tree of child-parent record dependancies, as
reflected by Elixir's descriptors) to let me know where I need to
add more permissions.

Since the above is not working I'll be monitoring the postgresql
logfile instead until the problem is fixed. This is not ideal
beacause I can only catch the permission problems during
development, and only if I remember to watch postgresql's log files.

-- System Information:
Debian Release: lenny/sid
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-2-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-sqlalchemy depends on:
ii  python                        2.4.4-6    An interactive high-level object-o
ii  python-central                0.5.15     register and build utility for Pyt

python-sqlalchemy recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to