I was writing a SQL method to pull one record out of a database that contains account information for the current authenticated user, and it's not recognizing the <!--#var AUTHENTICATED_USER--> in the ZSQL method: select * from accounts where name = '<!--#var AUTHENTICATED_USER-->'; Zope tells me: Error, exceptions.KeyError: AUTHENTICATED_USER SQL used: Could not render the query template! Substituting <!--#var AUTHENTICATED_USER--> with an actual name works fine. Any ideas on how to get this to work? Or am I going about this all wrong? Thanks, John
jcoleman@austin.rr.com wrote:
I was writing a SQL method to pull one record out of a database that contains account information for the current authenticated user, and it's not recognizing the <!--#var AUTHENTICATED_USER--> in the ZSQL method:
select * from accounts where name = '<!--#var AUTHENTICATED_USER-->';
Zope tells me:
Error, exceptions.KeyError: AUTHENTICATED_USER SQL used: Could not render the query template!
Substituting <!--#var AUTHENTICATED_USER--> with an actual name works fine. Any ideas on how to get this to work? Or am I going about this all wrong?
I believe the correct way to get the username would be: <!--#var "AUTHENTICATED_USER.getUserName()"--> untested.. Regards, David
Thanks, John
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
David Kankiewicz wrote:
jcoleman@austin.rr.com wrote:
I was writing a SQL method to pull one record out of a database that contains account information for the current authenticated user, and it's not recognizing the <!--#var AUTHENTICATED_USER--> in the ZSQL method:
select * from accounts where name = '<!--#var AUTHENTICATED_USER-->';
Zope tells me:
Error, exceptions.KeyError: AUTHENTICATED_USER SQL used: Could not render the query template!
Substituting <!--#var AUTHENTICATED_USER--> with an actual name works fine. Any ideas on how to get this to work? Or am I going about this all wrong?
I believe the correct way to get the username would be:
<!--#var "AUTHENTICATED_USER.getUserName()"-->
untested..
Regards, David
Hmm... nope, same thing. This is getting kind of frustrating. John
jcoleman@austin.rr.com wrote: ...
Error, exceptions.KeyError: AUTHENTICATED_USER SQL used: Could not render the query template!
Substituting <!--#var AUTHENTICATED_USER--> with an actual name works fine. Any ideas on how to get this to work? Or am I going about this all wrong?
I believe the correct way to get the username would be:
<!--#var "AUTHENTICATED_USER.getUserName()"-->
untested.. ... Hmm... nope, same thing. This is getting kind of frustrating.
John
<shot in the dark> try: where name = <!--#var AUTHENTICATED_USER--> I think the problem is in the ticks and semicolon ... </shot in the dark> Bill
+----[ jcoleman@austin.rr.com ]--------------------------------------------- | I was writing a SQL method to pull one record out of a database that | contains account information for the current authenticated user, and | it's not recognizing the <!--#var AUTHENTICATED_USER--> in the ZSQL | method: | | select * from accounts | where name = '<!--#var AUTHENTICATED_USER-->'; | | Zope tells me: | | | Error, exceptions.KeyError: AUTHENTICATED_USER | SQL used: | Could not render the query template! | | | Substituting <!--#var AUTHENTICATED_USER--> with an actual name works | fine. Any ideas on how to get this to work? Or am I going about this | all wrong? <!--#call "REQUEST.set('username',_.str(AUTHENTICATED_USER))" --> I use this, and then refer to username from then on. -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | Milton ACN: 082 081 472 | M:+61 416 022 411 |72 Col .Sig PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|Specialist
How about this, in the ZSQL Method: select * from accounts where name = <dtml-sqlvar AUTHENTICATED_USER> or maybe: name = <dtml-sqlvar "REQUEST['AUTHENTICATED_USER']"> or even: name = <dtml-sqlvar username> then in a DTML Method: <dtml-call "ZSQLMethod(username=REQUEST['AUTHENTICATED_USER']"> Hope these are somewhere in the ballpark. -Lance On 9 Sep, Andrew Kenneth Milton wrote:
+----[ jcoleman@austin.rr.com ]--------------------------------------------- | I was writing a SQL method to pull one record out of a database that | contains account information for the current authenticated user, and | it's not recognizing the <!--#var AUTHENTICATED_USER--> in the ZSQL | method: | | select * from accounts | where name = '<!--#var AUTHENTICATED_USER-->'; | | Zope tells me: | | | Error, exceptions.KeyError: AUTHENTICATED_USER | SQL used: | Could not render the query template! | | | Substituting <!--#var AUTHENTICATED_USER--> with an actual name works | fine. Any ideas on how to get this to work? Or am I going about this | all wrong?
<!--#call "REQUEST.set('username',_.str(AUTHENTICATED_USER))" -->
I use this, and then refer to username from then on.
The following snippet if from a working ZSQL Method that I use as wrapper to every data request. (There are a wide range of permissions that can changes dynamically - I am pulling the from our in house database which is in regular use by over 100 people internally. The Zope site I am devoloping will make this data available to our worldwide sales people and distributors.) "...from online where username == <!--#sqlvar "REQUEST.get('AUTHENTICATED_USER')" type=string-->" (haven't yet converted the code to the new DTML syntax.) ----- Original Message ----- From: Andrew Kenneth Milton <akm@mail.theinternet.com.au> To: <jcoleman@austin.rr.com> Cc: <zope@zope.org> Sent: Wednesday, September 08, 1999 9:51 PM Subject: Re: [Zope] Quick question on ZSQL methods...
+----[ jcoleman@austin.rr.com ]---------------------------------------------
| I was writing a SQL method to pull one record out of a database that | contains account information for the current authenticated user, and | it's not recognizing the <!--#var AUTHENTICATED_USER--> in the ZSQL | method: | | select * from accounts | where name = '<!--#var AUTHENTICATED_USER-->'; | | Zope tells me: | | | Error, exceptions.KeyError: AUTHENTICATED_USER | SQL used: | Could not render the query template! | | | Substituting <!--#var AUTHENTICATED_USER--> with an actual name works | fine. Any ideas on how to get this to work? Or am I going about this | all wrong?
<!--#call "REQUEST.set('username',_.str(AUTHENTICATED_USER))" -->
I use this, and then refer to username from then on.
-- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | Milton ACN: 082 081 472 | M:+61 416 022 411 |72 Col .Sig PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|Specialist
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
participants (6)
-
Andrew Kenneth Milton -
Bill Anderson -
David Kankiewicz -
jcoleman@austin.rr.com -
Jim Sanford -
Odysseus@interport.net