Zope DTML ZSQL method optional parameters

All parameters to a ZSQL method are optional, you can check for their existence using a basic dtml-if block, and append conditions accordingly.
<dtml-comment>
   title:Select user
   arguments: user_id active_only
   connection_id:MySQL_database_connection
   max_rows:15
   max_cache:300
   cache_time:0
   class_name:
   class_file:
</dtml-comment>
SELECT user_id, name, country, active_only
FROM user
WHERE 1 = 1
<dtml-if user_id>
	AND user_id = <dtml-sqlvar user_id type="string">
</dtml-if>
<dtml-if active_only>
	AND active = 1
</dtml-if>
ORDER BY ts_created DESC
Posted by
Snippet Viewed 2107 times.

Share your Zope DTML code snippets:

  • Get some recognition & link back to your site.

 

Submit | Browse

Most Recent zope dtml snippets

Most Viewed