[Zope] accessing custom properties of file objects

Jesse Goerz jgoerz@cfl.rr.com
21 Jun 2002 00:10:28 -0400


On Thu, 2002-06-20 at 15:40, Dieter Maurer wrote:
> Hmm, you do not tell us, it what way the other code does not work...
> 
>   exception? (which one, with Error Type/Value and tracebach)
>   wrong result?
>   something else?

Sorry about that.  I posted prematurely.  I seem to be able to test if
the property I created is there but I'd really like to base my
conditions on the value of the property.  Below is my amended code as
well as the tracebacks.

<table border="1" width="95%" bgcolor="#000000" cellspacing="2"
cellpadding="2" align="center"  
   tal:define="objects here/files;
   sort_on python:(('id', 'nocase', 'asc'),
   ('bobobase_modification_time', 'cmp', 'desc'));
   sorted_objects python:sequence.sort(objects, sort_on)">

 <tbody>
    <tr>
     <th>Filename</th>
     <th>Size</th>
     <th>Description</th>
     <th>Last modified</th>
  </tr>

  <tr tal:repeat="item sorted_objects">
<!-- 
This one displays all the file objects with a property of "section", but
I want to display based on the value of "section", i.e. there will be
multiple different sections throughout the html page, each in its own
table.
<div tal:condition="python:exists('item/section')"
-->
<div tal:condition="python:'item/section'=='c'"
     tal:omit-tag>
  
     <td>
      <a href="http://jesse.homelinux.net/sample"
         tal:attributes="href item/getId" 
         tal:content="item/getId">File_link</a>
     </td>
     <td tal:content="item/file_size">Type</td>
     <td tal:content="item/title">Description</td>
     <td tal:content="item/date_mod" align="center">Last modified</td>

</div>
  </tr>
 </tbody>  
</table>

The statement I'm working on here is:
<div tal:condition="python:'item/section'=='c'" tal:omit-tag>
That above gives no errors but outputs only one blank row.

This:
<div tal:condition="python:item.section=='c'" tal:omit-tag>
outputs these errors:

Traceback (innermost last):
  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 114, in
publish
  File /usr/lib/zope/lib/python/Zope/__init__.py, line 159, in
zpublisher_exception_hook
    (Object: file_library)
  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 98, in
publish
  File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply
    (Object: index_html)
  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 39, in
call_object
    (Object: index_html)
  File /usr/lib/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 252,
in __call__
    (Object: index_html)
  File /usr/lib/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 283,
in _bindAndExec
    (Object: index_html)
  File
/usr/lib/zope/lib/python/Products/PageTemplates/ZopePageTemplate.py,
line 210, in _exec
    (Object: index_html)
  File /usr/lib/zope/lib/python/Products/PageTemplates/PageTemplate.py,
line 86, in pt_render
    (Object: index_html)
  File /usr/lib/zope/lib/python/TAL/TALInterpreter.py, line 158, in
__call__
  File /usr/lib/zope/lib/python/TAL/TALInterpreter.py, line 191, in
interpret
  File /usr/lib/zope/lib/python/TAL/TALInterpreter.py, line 476, in
do_loop_tal
  File /usr/lib/zope/lib/python/TAL/TALInterpreter.py, line 191, in
interpret
  File /usr/lib/zope/lib/python/TAL/TALInterpreter.py, line 490, in
do_condition
  File /usr/lib/zope/lib/python/Products/PageTemplates/TALES.py, line
262, in evaluateBoolean
  File /usr/lib/zope/lib/python/Products/PageTemplates/TALES.py, line
247, in evaluate
  File /usr/lib/zope/lib/python/Products/PageTemplates/ZRPythonExpr.py,
line 49, in __call__
    (Info: item.section=='c')
  File Python expression &quot;item.section=='c'&quot;, line 2, in f
TALESError: (see above)

I've tried as many variations of the item/section as I could think of
but obviously not the one I need.

tia,
Jesse