LoginManager question
Hi, I am currently using LoginManager to authenticate users from a MySQL database. I followed the tutorials and it works quite well; but there are other data associated with users in the database that I would like to use in Zope. I have found a solution but I think it is quite complicated: - first, I added SQL_id_user (ZSQL-method) in the acl_users: select id_user from user where <dtml-sqltest username column=user_name type=string> - then, I added id_user (DTML-method) in the acl_users: <dtml-in expr="SQL_id_user(username=username)"> <dtml-return id_user> </dtml-in> - now, when I want to get the id_user value associated with the current user, I need to do: <dtml-with REQUEST> <dtml-var expr = "AUTHENTICATED_USER.id_user( AUTHENTICATED_USER, username=AUTHENTICATED_USER )"
</dtml-with> Isn't there an easier way to get the id_user value? -- Bertrand Croq - VIRTUAL NET (http://www.virtual-net.fr) 80, avenue des Buttes de Coesmes - 35700 RENNES tel: +33 2 23 21 06 30 - fax: +33 2 99 38 16 85
At 12:19 PM 3/27/01 +0200, Bertrand Croq wrote:
Hi, I am currently using LoginManager to authenticate users from a MySQL database. I followed the tutorials and it works quite well; but there are other data associated with users in the database that I would like to use in Zope. I have found a solution but I think it is quite complicated:
- first, I added SQL_id_user (ZSQL-method) in the acl_users:
select id_user from user where <dtml-sqltest username column=user_name type=string>
- then, I added id_user (DTML-method) in the acl_users:
<dtml-in expr="SQL_id_user(username=username)"> <dtml-return id_user> </dtml-in>
- now, when I want to get the id_user value associated with the current user, I need to do:
<dtml-with REQUEST> <dtml-var expr = "AUTHENTICATED_USER.id_user( AUTHENTICATED_USER, username=AUTHENTICATED_USER )"
</dtml-with>
Isn't there an easier way to get the id_user value?
Yes, there is. Get rid of the "id_user" DTML method and add the following to a SkinScript method inside your UserSource: WITH QUERY SQL_id_user(username=self.id) COMPUTE id_user You should then be able to do "AUTHENTICATED_USER.id_user" to retrieve the attribute.
Phillip J. Eby wrote :
Get rid of the "id_user" DTML method and add the following to a SkinScript method inside your UserSource:
WITH QUERY SQL_id_user(username=self.id) COMPUTE id_user
You should then be able to do "AUTHENTICATED_USER.id_user" to retrieve the attribute.
I had to update ZPatterns (md error) and configure STUPID_LOG_FILE (I/O error) but it works. Thanks a lot. -- Bertrand Croq - VIRTUAL NET (http://www.virtual-net.fr) 80, avenue des Buttes de Coesmes - 35700 RENNES tel: +33 2 23 21 06 30 - fax: +33 2 99 38 16 85
participants (2)
-
Bertrand Croq -
Phillip J. Eby