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

Charlie Clark charlie@begeistert.org
Mon, 06 Jan 2003 18:56:22 +0100


> -----
> 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?

Sure,

you can call a ZSQL-method at any time and pass it parameters.

<div tal:define="results python: here.SQLmethod(username=user.getUserName)" 
tal:repeat="result results">
<br tal:content="result/group_value">
</div>

should work or require minimal modification - untested!

Charlie