[Zope] exUserFolder + MySQL + Python syntax problem

David Washburn dwashburn@aminfo.com
Mon, 28 Jul 2003 16:38:44 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C35526.B5CC7720
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I am having trouble accessing the API functions in exUserFolder.

I am using exUserFolder because I need to merge user data and properties
with a MySQL database table.

I have taken the approach of making one "account" table that has many
properties of a user (first_name, last_name, title, office_telephone....). I
did this because some of this data will be maintained by an application
outside of ZOPE and the single record approach works best for that
configuration.

What I want to do is, at login time, load various fields from that "account"
table into temporary properties that I can access throughout the site. To do
this, I built a LoadProperties Python script that looks like this:
=================================================
MyUsername = context.REQUEST.AUTHENTICATED_USER

context.REQUEST.AUTHENTICATED_USER.flushTempProperties

for user in container.ListUsers(username=MyUsername):
   context.REQUEST.AUTHENTICATED_USER.setTempProperty('account_id' ,
user.account_id )
   context.REQUEST.AUTHENTICATED_USER.setTempProperty('username'   ,
user.username )
   context.REQUEST.AUTHENTICATED_USER.setTempProperty('user_type'  ,
user.user_type )

return
===================================================
and it calls a ZSQL Method called "ListUsers" to retrieve the current user.
I've tested that and it works.

What I can't seem to get working is the ".flushTempProperties" and
".setTempProperty" calls.
I call ".flushTempProperties" because I want to clear all temporary
properties before I load new values from the "account" table.

The syntax <dtml-var "AUTHENTICATED_USER.getProperty('full_name', '')>
worked in a DTML document to retrieve a properties which I placed into the
"account" table where user info is stored.

Can someone suggest the correct syntax to access the ".flushTempProperties"
and ".setTempProperty" functions inside my Python Module?

Thank you for you time,
David
=======================================
David T. Washburn DWashburn@AmInfo.com
Amherst, MA USA
413 256-3103

------=_NextPart_000_0010_01C35526.B5CC7720
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR></HEAD>
<BODY>
<DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial><FONT =
size=3D2><SPAN=20
class=3D277383420-28072003>I am having trouble accessing the API =
functions in=20
exUserFolder.</SPAN> </FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial><FONT=20
size=3D2></FONT></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial><FONT =
size=3D2>I am using=20
exUserFolder because I need to merge user data and properties with a =
MySQL=20
database table.</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial size=3D2>I have =
taken the=20
approach of making one "account" table that has many properties of a =
user=20
(first_name, last_name, title, office_telephone....). I did this because =
some of=20
this data will be maintained by an application outside of ZOPE and the =
single=20
record approach works best for that configuration. </FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial size=3D2>What I =
want to do=20
is, at login time, load various fields from =
that&nbsp;"account"&nbsp;table into=20
temporary properties that I can access throughout the site. To do this, =
I built=20
a LoadProperties Python script that looks like this:</FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D</FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial =
size=3D2>MyUsername =3D=20
context.REQUEST.AUTHENTICATED_USER<BR></FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2>context.REQUEST.AUTHENTICATED_USER.flushTempProperties</FONT></S=
PAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial size=3D2>for =
user in=20
container.ListUsers(username=3DMyUsername):<BR>&nbsp;&nbsp;=20
context.REQUEST.AUTHENTICATED_USER.setTempProperty('account_id' ,=20
user.account_id )<BR>&nbsp;&nbsp;=20
context.REQUEST.AUTHENTICATED_USER.setTempProperty('username'&nbsp;&nbsp;=
 ,=20
user.username )<BR>&nbsp;&nbsp;=20
context.REQUEST.AUTHENTICATED_USER.setTempProperty('user_type'&nbsp; ,=20
user.user_type )</FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2>return</FONT></SPAN></DIV>
<DIV><SPAN class=3D589021820-28072003><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D</FONT></SPAN></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D589021820-28072003>and it =
calls a ZSQL=20
Method called "ListUsers" to retrieve the current user.&nbsp;<SPAN=20
class=3D277383420-28072003>I've tested that and it</SPAN>=20
works.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D589021820-28072003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D589021820-28072003>What I =
can't seem to=20
get working is the&nbsp;<SPAN=20
class=3D277383420-28072003>"</SPAN>.flushTempProperties<SPAN=20
class=3D277383420-28072003>"</SPAN> and&nbsp;<SPAN=20
class=3D277383420-28072003>"</SPAN>.setTempProperty<SPAN=20
class=3D277383420-28072003>"</SPAN> calls. </SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D589021820-28072003>I =
call&nbsp;<SPAN=20
class=3D277383420-28072003>"</SPAN>.flushTempProperties<SPAN=20
class=3D277383420-28072003>"</SPAN> because I want to clear&nbsp;all=20
temporary&nbsp;properties before I load new values from the "account"=20
table.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D589021820-28072003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D589021820-28072003>The =
syntax=20
&lt;dtml-var "AUTHENTICATED_USER.getProperty('full_name', '')&gt; worked =
in a=20
DTML document to retrieve a properties which I placed into the "account" =
table=20
where user info is stored.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D589021820-28072003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D589021820-28072003>Can&nbsp;<SPAN=20
class=3D277383420-28072003>someone</SPAN> suggest the correct syntax to =
access the=20
".flushTempProperties" and ".setTempProperty" =
functions&nbsp;inside&nbsp;my=20
Python Module?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D589021820-28072003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D589021820-28072003>Thank =
you for you=20
time,</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D589021820-28072003>David&nbsp;</SPAN></FONT><SPAN=20
class=3D589021820-28072003></DIV></SPAN>
<DIV><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>David T. Washburn </FONT><A=20
href=3D"mailto:DWashburn@AmInfo.com"><FONT=20
size=3D2>DWashburn@AmInfo.com</FONT></A></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Amherst, MA USA</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>413 256-310<SPAN=20
class=3D277383420-28072003>3</SPAN></FONT></FONT></DIV></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0010_01C35526.B5CC7720--