I'm trying to pass a keyword argument to a function (in this case Catalog), but to generate it from variables. The following doesn't work, but it illustrates my idea: <dtml-in "Catalog(_.getitem(search_in) = _.getitem(search_for))"> The obvious way to do this in python would be to use the 'exec' command - but that doesn't seem to work in zope. Is there any way to do this in zope? -Ed -- Andrew Edmondson
On Tue, 23 May 2000, Andrew Edmondson wrote:
The following doesn't work, but it illustrates my idea: <dtml-in "Catalog(_.getitem(search_in) = _.getitem(search_for))">
The obvious way to do this in python would be to use the 'exec' command - but that doesn't seem to work in zope.
Is there any way to do this in zope?
You will probably have to write an external method to do it the way you show. Exec is disallowed in DTML for security reasons, and I at least can't think of any other way to pass a named parameter in to a procedure call if you don't know the name of the paramter until run time. On the other hand, if you call the catalog via just <dtml-in Catalog> it will pull its search fields out of the REQUEST variable. If you can arrange it so that REQUEST contains just the appropriate search variables set to the appropriate search values, you should be home free. --RDM
R. David Murray writes:
On Tue, 23 May 2000, Andrew Edmondson wrote:
The following doesn't work, but it illustrates my idea: <dtml-in "Catalog(_.getitem(search_in) = _.getitem(search_for))"> ...snip... On the other hand, if you call the catalog via just
<dtml-in Catalog>
it will pull its search fields out of the REQUEST variable. If you can arrange it so that REQUEST contains just the appropriate search variables set to the appropriate search values, you should be home free.
Or you can search the Catalog like this: <dtml-in "Catalog.searchResults({'category':category_id, 'item_type':'book'})"> I.E. put all the search parameters in a dictionary and pass that instead of REQUEST. I use this instead of REQUEST because it's too easy for REQUEST to get polluted with other variables whose names are search fields.
Andrew Edmondson writes:
I'm trying to pass a keyword argument to a function (in this case Catalog), but to generate it from variables.
Try: (untested)
The following doesn't work, but it illustrates my idea: <dtml-in "Catalog(_.getitem(search_in, 1) = _.getitem(search_for, 1))">
The obvious way to do this in python would be to use the 'exec' command - but that doesn't seem to work in zope.
Is there any way to do this in zope?
-Ed
-- Andrew Edmondson
All my best, Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
participants (4)
-
Andrew Edmondson -
Dan L. Pierson -
Jason Spisak -
R. David Murray