[Zope-DB] how to pass an argument into a Z SQL method without using a form?

Ben Avery ben@thesite.org
Mon, 06 Jan 2003 17:38:20 +0000


I'm not too hot on ZPT, maybe you could put a python expression in the 
call to your zsql method to grab the AUTHENTICATED_USER value.
failing that, you could put a python script wrapper around the zsql 
method to get the authenticated user and pass it into the script.

----
user=container.REQUEST.AUTHENTICATED_USER

group_val_dict=context.gv_zsql(user).dictionaries()[0]
group_val=group_val_dict['GROUP_VALUE']

return group_val
---

where gv_zsql is the name of your zsql method, somewhere in the 
acquisition path


HTH

Ben


Robert Van Overmeiren wrote:
> Hello,
> 
> My question has to do with passing an argument into a Z SQL method without
> having to use, or submit, a form.
> 
> -----
> The SQL is like this:
> SELECT GROUP_VALUE FROM APPUSER WHERE USERNAME = <dtml-sqlvar username
> type=string>
> -----
> 
> I want the current Zope user's name to be automatically inserted in place of
> the username argument. Can "user/getUserName" be used here somewhere?
> 
> This SQL is called from a page template. If the Z SQL method can't request
> and insert the Zope user value, then can it be requested and passed to the
> SQL from the page template somehow?
> 
> Thx
> Bob Van
> 
> 
> _______________________________________________
> Zope-DB mailing list
> Zope-DB@zope.org
> http://lists.zope.org/mailman/listinfo/zope-db
>