[Zope] traversal problem

Garito garito at sistes.net
Sat Mar 5 14:05:17 EST 2005


john blair escribió:

>I tried this
><p tal:define="category_id
>request/form/category;category python:getattr(here,
>category_id);"> </p>
>  <table>
>    <tr tal:repeat="item category/objectValues"> 
>          <td tal:content="item/id">Id</td>
>          <td tal:content="item/title">Title</td>
>    </tr>
>
>    </table> 
>
>It still gives
>
>Error Type: KeyError
>Error Value: 'category'
>
>
>--- "SER.RI-TIC-Alexis Roda" <alexis.roda at urv.net>
>wrote:
>
>  
>
>>john blair wrote:
>>    
>>
>>>Hi I have say 3 folders with following ids
>>>folder1
>>>folder2
>>>folder3
>>>
>>>Now I show this list to the user in a comno box.
>>>      
>>>
>>User
>>    
>>
>>>selects folder which results in displaying of the
>>>contents of that folder.
>>>Say the select box name is category
>>>i.e <select name="category">
>>>now when the user selects one of the category what
>>>      
>>>
>>I
>>    
>>
>>>do is
>>><p tal:define="category request/form/category">
>>>      
>>>
>></p>
>>    
>>
>>>  <table>
>>>    <tr tal:repeat="item category/objectValues"> 
>>>          <td tal:content="item/id">Id</td>
>>>          <td tal:content="item/title">Title</td>
>>>    </tr>
>>></table>
>>>
>>>It gives me a key error .What should I do to
>>>      
>>>
>>correctly
>>    
>>
>>>traverse the folder
>>>      
>>>
>>category is a string, try with something like:
>>
>><div tal:define="category_id request/form/category;
>>                  category python:getattr(here,
>>category_id);
>>                 ">
>>  ...
>></div>
>>
>>
>>
>>HTH
>>-- 
>>                                    ////
>>                                   (@ @)
>>
>>    
>>
>----------------------------oOO----(_)----OOo--------------------------
>  
>
>><>               Ojo por ojo y el mundo acabara
>>ciego
>>/\ Alexis Roda - Universitat Rovira i Virgili -
>>Reus, Tarragona (Spain)
>>
>>    
>>
>-----------------------------------------------------------------------
>  
>
>>_______________________________________________
>>Zope maillist  -  Zope at zope.org
>>http://mail.zope.org/mailman/listinfo/zope
>>**   No cross posts or HTML encoding!  **
>>(Related lists - 
>> http://mail.zope.org/mailman/listinfo/zope-announce
>> http://mail.zope.org/mailman/listinfo/zope-dev )
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>_______________________________________________
>Zope maillist  -  Zope at zope.org
>http://mail.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists - 
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>  
>
Try:

<p tal:define="category_id
request/form/category;*global* category python:getattr(here,
category_id);"> </p>
  <table>
    <tr tal:repeat="item category/objectValues"> 
          <td tal:content="item/id">Id</td>
          <td tal:content="item/title">Title</td>
    </tr>

    </table>


or

<p tal:define="category_id
request/form/category;category python:getattr(here,
category_id);">
  <table>
    <tr tal:repeat="item category/objectValues"> 
          <td tal:content="item/id">Id</td>
          <td tal:content="item/title">Title</td>
    </tr>

    </table>


*</p>*




More information about the Zope mailing list