Re: brain hurts regarding dynamic fcn args in Python
--- In zope@egroups.com, jeff@s... ("Jeff Sasmor") wrote:
<dtml-in "Catalog.searchResults(meta_type='EventDoc',event_date=[first,last],event_date_usage='range:min:max',sort_on='event_date ')"> ....
Now if the 'moderated' property is active I want to add the keyword arg
reviewed='on'
to the arg list at the time that the searchResults method is invoked.
Hmm... I have had to do something similar recently. But I did not use dynamical argument list. If your choices are simple enough, you could do: ------------------------------------------------------ <dtml-if "moderated == 'active'"> <dtml-in "Catalog.searchResults(meta_type='EventDoc',event_date=[first,last],event_date_usage='range:min:max',review='on',sort_on='event_date
')"> <dtml-var shared_dtml> <dtml-in>
<dtml-else> <dtml-in "Catalog.searchResults(meta_type='EventDoc',event_date=[first,last],event_date_usage='range:min:max',sort_on='event_date
')"> <dtml-var shared_dtml> <dtml-in>
</dtml-if> ------------------------------------------------------ Yes, the shared_dtml will still have full access to all the "sequence-item" type of variables. If you have to check more than a few properties, then the above construction might not be so good. If you can always pass a value to a keyword argument, then it's best to use an aux variable and preset the value of the argument. <dtml-if "moderated == 'active'"> <dtml-call "REQUEST.set('review', 'on')"> <dtml-else> <dtml-call "REQUEST.set('review', 'off')"> </dtml-if> <dtml-in "Catalog.searchResults(meta_type='EventDoc',event_date=[first,last],event_date_usage='range:min:max',review=review,sort_on='event_date
')"> ... </dtml-in>
Hung Jung ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
participants (1)
-
Hung Jung Lu