[Zope] Puzzling DTML method results
Michel Pelletier
michel@digicool.com
Wed, 08 Mar 2000 13:54:37 -0800
"James W. Howe" wrote:
>
> I'm encoutering a puzzling result with some DTMLMethods that I've
> written. I have some code which is used to display a list of information
> derived from a catalog. The information presented varies, based on which
> "category" of information the user desires. The DTMLMethod which generates
> most of this information looks like this:
>
> <dtml-in "InternetLinkCatalog(meta_type='Internet Link Info',
> categories=_['categoryName'])" sort=name>
> <dtml-with "InternetLinkCatalog.getobject(data_record_id_)">
> < ... display object stuff here ... >
> </dtml-with>
> </dtml-in>
>
> For testing purposes, I created another DTMLMethod in the same folder named
> 'categoryName' and initially all it contained was one line:
>
> Accounting
>
> When I displayed the contents of my folder (which utilizes the list
> generation method), I received a list of all objects which belonged to the
> category of Accounting. I'm now trying to extend my code to use an actual
> category name specified by a user (or from a url clicked on by the
> user). I changed my 'categoryName' code to look like this:
>
> <dtml-with REQUEST only>
> <dtml-if category>
> <dtml-var category>
> <dtml-else>
> Accounting
> </dtml-if>
> </dtml-with>
I can't see the problem either, but I suggest changing your method to
this:
<dtml-if category>
<dtml-return category>
<dtml-else>
<dtml-return "'Accounting'">
</dtml-if>
The <dtml-with> is unecessary. Note the single quotes inside the double
quotes.
This might fix it, might not, not sure. But here you are explicitly
returning a string, not a formatted document.
-Michel