[Zope] brain hurts regarding dynamic fcn args in Python
Jeff Sasmor
jeff@sasmor.com
19 Jun 2000 22:50:36 +0200
Hi- I guess I'm somewhere past a 'newbie' (after a few solid months)
and I'm developing a calendar-based (but not based on calendar tag)
'event-log' 'black-box app' for lack of a better term, for eventual relase
to Zope.org, if only as a helper for _new_ newbies.
I'm stuck on what I guess is a pythonish thing and my brain hurts.
Is there a (straightforward?) way to dynamically compose function
argument lists? For example, in C, you can write"
f(arg1, arg2, (conditional expression)?(val for TRUE state):(val for FALSE state)).
Or one can embed a fcn call within an argument list in order to supply a
needed function parameter.
In my case here in Zope, sometimes I have to search a ZCatalog
prior to displaying the results in a <dtml-in> looping construct.
<dtml-in
"Catalog.searchResults(meta_type='EventDoc',event_date=[first,last],event_date_usage='range:min:max',sort_on='event_date
')">
....
</dtml-in>
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.
Since this invokation is in an expression it's certainly a python thing, but I can't find
any reference to this type of capability in any reference I have. Did I miss something or
is there just no simple way to do this?
The only way I can see to do it is to wrap Catalog.searchResults() in an external method with
some ifs and elifs.
TIA.
Jeff Sasmor
jeff@sasmor.com
_______________________________________________
Zope maillist - Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )
---