[Zope] <dtml-in> problem with defined or not defined variable
as parameter
Johan Carlsson
johanc at easypublisher.com
Thu Sep 9 04:56:16 EDT 2004
Patrick Ulmer wrote:
> Hi,
>
>>> I want to do something like that:
>>>
>>> <dtml-if id_historie>
>>> <dtml-in expr="dbSelect(id_historie=_.str(id_historie))">
>>> <dtml-else>
>>> <dtml-in expr="dbSelect(id_historie=_.str(0))">
>>> <dtml-if>
>>>
>>> [...]
>>>
>>> </dtml-in>
>>>
>>> but I get the error " unexpected end tag, for tag </dtml-in>". How
>>> can I query my database depending on having id_historie defined or
>>> not? Can somebody give me a hint?
>>
>>
>>
>> In the exaple above I would set id_historie in a <dtml-let> tag:
>>
>> <dtml-let id_historie="id_historie or 0">
>> <dtml-in expr="dbSelect(id_historie=_.str(id_historie))">
>> ...
>> </dtml-in>
>> </dtml-let>
>
>
>
> Sorry, but now I got the error "global name 'id_historie' is not
> defined" in line <dtml-let....>.
<dtml-let id_historie="_.getattr(_, 'id_historie', 0)">
or
<dtml-let id_historie="_.has_key('id_historie') and id_historie or 0)">
--
Johan Carlsson Tel: + 46 8 31 24 94
Colliberty Mob: + 46 70 558 25 24
Torsgatan 72 Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM
More information about the Zope
mailing list