Re: [Zope] ZSQL with different user

2005-12-20 Thread Pier Luigi Fiorini
Alle 18:42, lunedì 19 dicembre 2005, hai scritto:
 Pier Luigi Fiorini wrote:
  Hello,
  I'm developing a Zope application that uses a PostgreSQL connection and
  several ZSQL objects.
  People should log in using a Postgres user and ZSQL object should be
  executed by the user that's logged in. Multiple people can be logged at
  the same time. Unfortunately it is not possible because the same Postgres
  connection is used by all the ZSQL object. Is there a way to change the
  user executing a ZSQL query?
 
  An alternative would be to log into the event.log some information (like
  the username, that's stored in the session) and the query source.

 Your alternative is dead easy. zLOG (or, better, the Python logging
 module, for which zLOG is now a facade) is quite easy to use. You can
 even make your own log file to contain only such events.
I know _how_ to use zLOG. I just don't know how to log the query source.
Is there some documentation about these things. I can find only documentation 
about making things like a simple form which is not so useful because you can 
learn it in some days.
-- 
YACME S.r.l.
Via del Mobiliere, 9 40138 Bologna
Tel: +39 051 538709
Fax: +39 051 532399
[EMAIL PROTECTED]
www.yacme.com


pgp3kODOcvUzE.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZSQL with different user

2005-12-20 Thread J Cameron Cooper

Pier Luigi Fiorini wrote:

Alle 18:42, lunedì 19 dicembre 2005, hai scritto:


Pier Luigi Fiorini wrote:


Hello,
I'm developing a Zope application that uses a PostgreSQL connection and
several ZSQL objects.
People should log in using a Postgres user and ZSQL object should be
executed by the user that's logged in. Multiple people can be logged at
the same time. Unfortunately it is not possible because the same Postgres
connection is used by all the ZSQL object. Is there a way to change the
user executing a ZSQL query?

An alternative would be to log into the event.log some information (like
the username, that's stored in the session) and the query source.


Your alternative is dead easy. zLOG (or, better, the Python logging
module, for which zLOG is now a facade) is quite easy to use. You can
even make your own log file to contain only such events.


I know _how_ to use zLOG. I just don't know how to log the query source.
Is there some documentation about these things. I can find only documentation 
about making things like a simple form which is not so useful because you can 
learn it in some days.


That depends. What do you mean by query source?

--jcc
--
Building Websites with Plone
http://plonebook.packtpub.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] ZSQL with different user

2005-12-19 Thread Pier Luigi Fiorini
Hello,
I'm developing a Zope application that uses a PostgreSQL connection and 
several ZSQL objects.
People should log in using a Postgres user and ZSQL object should be executed 
by the user that's logged in. Multiple people can be logged at the same time.
Unfortunately it is not possible because the same Postgres connection is used 
by all the ZSQL object. Is there a way to change the user executing a ZSQL 
query?

An alternative would be to log into the event.log some information (like the 
username, that's stored in the session) and the query source.

Can you point me to some information?

Thanks
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZSQL with different user

2005-12-19 Thread Tino Wildenhain

Pier Luigi Fiorini schrieb:

Hello,
I'm developing a Zope application that uses a PostgreSQL connection and 
several ZSQL objects.
People should log in using a Postgres user and ZSQL object should be executed 
by the user that's logged in. Multiple people can be logged at the same time.
Unfortunately it is not possible because the same Postgres connection is used 
by all the ZSQL object. Is there a way to change the user executing a ZSQL 
query?


Well good news and bad news...
Good news first:

yes it can be done

Bad news:

you would have to code it ;)

You could base on the database adapter you currently
have but organize your connection pool on a per
user basis - so you need a connection with
a user-folder as well (Interesting
if you could subclass Userfolder and PsycopgDA...)
so when a user logs in you look in the connection
pool and/or authorize the user and use an idle/new
connection for this user when ZSQL methods are called.

Interesting project but not so easy.

Also in worst case you could end up having

zope-threads X users connection to your database.

And connection setup is somewhat expensive,
so if your pool is too small performance will suffer.

Regards
Tino
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZSQL with different user

2005-12-19 Thread Reinoud van Leeuwen
On Mon, Dec 19, 2005 at 03:39:51PM +0100, Tino Wildenhain wrote:
 Pier Luigi Fiorini schrieb:
 Hello,
 I'm developing a Zope application that uses a PostgreSQL connection and 
 several ZSQL objects.
 People should log in using a Postgres user and ZSQL object should be 
 executed by the user that's logged in. Multiple people can be logged at 
 the same time.
 Unfortunately it is not possible because the same Postgres connection is 
 used by all the ZSQL object. Is there a way to change the user executing a 
 ZSQL query?
 
 Well good news and bad news...
 Good news first:
 
 yes it can be done
 
 Bad news:
 
 you would have to code it ;)
 
 You could base on the database adapter you currently
 have but organize your connection pool on a per
 user basis - so you need a connection with
 a user-folder as well (Interesting
 if you could subclass Userfolder and PsycopgDA...)
 so when a user logs in you look in the connection
 pool and/or authorize the user and use an idle/new
 connection for this user when ZSQL methods are called.
 
 Interesting project but not so easy.
 
 Also in worst case you could end up having
 
 zope-threads X users connection to your database.
 
 And connection setup is somewhat expensive,
 so if your pool is too small performance will suffer.

The postgresql commandline tool psql has a command /user to change the 
details of the current connection. Wouldn't it be easier to use a command 
like that at the beginning of each database request? 

(I think that would still need some hacking in Userfolder and/or 
PsycopgDA, or even in Psyco itself...)


-- 
__
Nothing is as subjective as reality
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZSQL with different user

2005-12-19 Thread Andreas Jung



--On 19. Dezember 2005 15:32:46 +0100 Pier Luigi Fiorini 
[EMAIL PROTECTED] wrote:



Hello,
I'm developing a Zope application that uses a PostgreSQL connection and
several ZSQL objects.
People should log in using a Postgres user and ZSQL object should be
executed  by the user that's logged in. Multiple people can be logged at
the same time. Unfortunately it is not possible because the same Postgres
connection is used  by all the ZSQL object. Is there a way to change the
user executing a ZSQL  query?



The short version: forget it. DA connections are tied to a particular user.
Connections are persistent and shared across threads and requests. You 
really don't want to connect/re-connect for every request and user. You 
would have to implement your own connection management including connection

pooling *somehow*.

-aj

pgpQhnV4SPuHW.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZSQL with different user

2005-12-19 Thread Tino Wildenhain
Am Montag, den 19.12.2005, 15:43 +0100 schrieb Reinoud van Leeuwen:

 The postgresql commandline tool psql has a command /user to change the 
 details of the current connection. Wouldn't it be easier to use a command 
 like that at the beginning of each database request? 

Well this \connect command really reconnecting.
There is SET SESSION AUTHORIZATION but I'm not
sure if it really helps.

Regards
Tino Wildenhain

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )