[Zope] passing parameter problem

Alexis Roda alexis.roda at urv.es
Thu Sep 16 04:07:34 EDT 2004


Laura McCord wrote:
> I tried what you suggested and that did not work either. actStatus will
> not be null.
> tal:define="actStatus result/Active_Inactive" returns either active or
> inactive and that is working correctly. 

 From what I know from your page template it is equivalent to:

<div tal:define="actStatus template/title;
                  colorStat python:actStatus + ' and this is foo'"
      tal:content="colorStat">
</div>

get a value from somewhere and calculate a second value based on first 
value. That works ok so your problem should be with actStatus 
initialization or with statChk script.

> This is what my python script looks like which includes a parameter,
> actStatus:
> if actStatus == 'active':
>  return "#000"
> if actStatus == 'inactive':
>  return "#b7b7b7"

If actStatus is not 'active' nor 'inactive' the script will return None. 
IIRC None is tal Nothing and you're using colorStat in a tal:attributes, 
which interprets Nothing as "remove the attribute". Try adding a

raise ValueError('actStatus="%s"' % repr(actStatus))

statement at the end of the script, just to be sure that the script gets 
a valid actStatus and returns a color.

If statChk is just the four lines you send it could be replaced by 
something like:

colorStat python:test(actStatus == 'active', '#000', '#b7b7b7')



HTH
-- 
                                    ////
                                   (@ @)
----------------------------oOO----(_)----OOo--------------------------
<>               Ojo por ojo y el mundo acabara ciego
/\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
-----------------------------------------------------------------------



More information about the Zope mailing list