[Zope] Get all folder objects in a folder

Oliver Marx oliver@tekk.dk
Wed, 3 Jul 2002 16:08:43 +0200


I have been there :D

This is the error I get:

exceptions.AttributeError on list_folders in '', at line 3, column 1
Traceback (innermost last):
  File C:\PROGRA~1\Emma\lib\python\ZPublisher\Publish.py, line 150, in
publish_module
  File C:\PROGRA~1\Emma\lib\python\ZPublisher\Publish.py, line 114, in
publish
  File C:\PROGRA~1\Emma\lib\python\Zope\__init__.py, line 159, in
zpublisher_exception_hook
    (Object: custom)
  File C:\PROGRA~1\Emma\lib\python\ZPublisher\Publish.py, line 98, in
publish
  File C:\PROGRA~1\Emma\lib\python\ZPublisher\mapply.py, line 88, in mapply
    (Object: main_left_column)
  File C:\PROGRA~1\Emma\lib\python\ZPublisher\Publish.py, line 39, in
call_object
    (Object: main_left_column)
  File C:\PROGRA~1\Emma\lib\python\Shared\DC\Scripts\Bindings.py, line 252,
in __call__
    (Object: main_left_column)
  File C:\PROGRA~1\Emma\lib\python\Shared\DC\Scripts\Bindings.py, line 283,
in _bindAndExec
    (Object: main_left_column)
  File
C:\PROGRA~1\Emma\lib\python\Products\PageTemplates\ZopePageTemplate.py, line
210, in _exec
    (Object: main_left_column)
  File C:\PROGRA~1\Emma\lib\python\Products\PageTemplates\PageTemplate.py,
line 86, in pt_render
    (Object: main_left_column)
    (Info: {'container': <Folder instance at 019C1870>,
 'here': <Folder instance at 019C1870>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter
instance at 01066574>,
 'nothing': None,
 'options': {'args': ()},
 'request': <h3>form</h3><table></table><h3>cookies</h3><table><tr
valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW/XYWAAtiQTP'</td></tr><tr
valign="top" align="left"><th>sql_pref__cols</th><td>'50'</td></tr><tr
valign="top" align="left"><th>dtpref_cols</th><td>'45'</td></tr><tr
valign="top" align="left"><th>sql_pref__rows</th><td>'15'</td></tr><tr
valign="top"
align="left"><th>dtpref_rows</th><td>'20'</td></tr></table><h3>lazy
items</h3><table><tr valign="top"
align="left"><th>SESSION</th><td>&lt;Python Method object at
01667160&gt;</td></tr></table><h3>other</h3><table><tr valign="top"
align="left"><th>dtpref_rows</th><td>'20'</td></tr><tr valign="top"
align="left"><th>BASE4</th><td>'http://emma:8080/TEKK/portal_skins/custom'</
td></tr><tr valign="top"
align="left"><th>BASE5</th><td>'http://emma:8080/TEKK/portal_skins/custom/ma
in_left_column'</td></tr><tr valign="top"
align="left"><th>dtpref_cols</th><td>'45'</td></tr><tr valign="top"
align="left"><th>BASE3</th><td>'http://emma:8080/TEKK/portal_skins'</td></tr
><tr valign="top"
align="left"><th>URL2</th><td>'http://emma:8080/TEKK/portal_skins'</td></tr>
<tr valign="top"
align="left"><th>BASE1</th><td>'http://emma:8080'</td></tr><tr valign="top"
align="left"><th>BASE0</th><td>'http://emma:8080'</td></tr><tr valign="top"
align="left"><th>URL1</th><td>'http://emma:8080/TEKK/portal_skins/custom'</t
d></tr><tr valign="top"
align="left"><th>SERVER_URL</th><td>'http://emma:8080'</td></tr><tr
valign="top" align="left"><th>AUTHENTICATED_USER</th><td>Oliver</td></tr><tr
valign="top"
align="left"><th>TraversalRequestNameStack</th><td>[]</td></tr><tr
valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW/XYWAAtiQTP'</td></tr><tr
valign="top" align="left"><th>AUTHENTICATION_PATH</th><td>''</td></tr><tr
valign="top" align="left"><th>sql_pref__rows</th><td>'15'</td></tr><tr
valign="top" align="left"><th>traverse_subpath</th><td>[]</td></tr><tr
valign="top"
align="left"><th>URL3</th><td>'http://emma:8080/TEKK'</td></tr><tr
valign="top"
align="left"><th>URL0</th><td>'http://emma:8080/TEKK/portal_skins/custom/mai
n_left_column'</td></tr><tr valign="top"
align="left"><th>URL4</th><td>'http://emma:8080'</td></tr><tr valign="top"
align="left"><th>sql_pref__cols</th><td>'50'</td></tr><tr valign="top"
align="left"><th>PUBLISHED</th><td>&lt;ZopePageTemplate instance at
015EC430&gt;</td></tr><tr valign="top"
align="left"><th>URL</th><td>'http://emma:8080/TEKK/portal_skins/custom/main
_left_column'</td></tr><tr valign="top"
align="left"><th>BASE2</th><td>'http://emma:8080/TEKK'</td></tr><tr
valign="top"
align="left"><th>URL0</th><td>http://emma:8080/TEKK/portal_skins/custom/main
_left_column</td></tr><tr valign="top"
align="left"><th>URL1</th><td>http://emma:8080/TEKK/portal_skins/custom</td>
</tr><tr valign="top"
align="left"><th>URL2</th><td>http://emma:8080/TEKK/portal_skins</td></tr><t
r valign="top"
align="left"><th>URL3</th><td>http://emma:8080/TEKK</td></tr><tr
valign="top" align="left"><th>URL4</th><td>http://emma:8080</td></tr><tr
valign="top" align="left"><th>BASE0</th><td>http://emma:8080</td></tr><tr
valign="top" align="left"><th>BASE1</th><td>http://emma:8080</td></tr><tr
valign="top"
align="left"><th>BASE2</th><td>http://emma:8080/TEKK</td></tr><tr
valign="top"
align="left"><th>BASE3</th><td>http://emma:8080/TEKK/portal_skins</td></tr><
tr valign="top"
align="left"><th>BASE4</th><td>http://emma:8080/TEKK/portal_skins/custom</td
></tr><tr valign="top"
align="left"><th>BASE5</th><td>http://emma:8080/TEKK/portal_skins/custom/mai
n_left_column</td></tr></table><h3>environ</h3><table><tr valign="top"
align="left"><th>HTTP_ACCEPT_ENCODING</th><td>'gzip, deflate'</td></tr><tr
valign="top"
align="left"><th>channel.creation_time</th><td>1025704596</td></tr><tr
valign="top"
align="left"><th>SERVER_PROTOCOL</th><td>'HTTP/1.1'</td></tr><tr
valign="top" align="left"><th>SERVER_PORT</th><td>'8080'</td></tr><tr
valign="top"
align="left"><th>PATH_INFO</th><td>'/TEKK/portal_skins/custom/main_left_colu
mn'</td></tr><tr valign="top"
align="left"><th>HTTP_HOST</th><td>'emma:8080'</td></tr><tr valign="top"
align="left"><th>REQUEST_METHOD</th><td>'GET'</td></tr><tr valign="top"
align="left"><th>PATH_TRANSLATED</th><td>'\\TEKK\\portal_skins\\custom\\main
_left_column'</td></tr><tr valign="top"
align="left"><th>HTTP_COOKIE</th><td>'sql_pref__rows="15";
sql_pref__cols="50"; dtpref_rows="20"; dtpref_cols="45";
tree-s="eJyLjlZ3hANPW/XYWAAtiQTP"'</td></tr><tr valign="top"
align="left"><th>SCRIPT_NAME</th><td>''</td></tr><tr valign="top"
align="left"><th>SERVER_SOFTWARE</th><td>'Zope/(Zope 2.5.1 (binary release,
python 2.1, win32-x86), python 2.1.3, win32) ZServer/1.1b1'</td></tr><tr
valign="top" align="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>'da'</td></tr><tr
valign="top" align="left"><th>HTTP_ACCEPT</th><td>'image/gif,
image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint,
application/vnd.ms-excel, application/msword, */*'</td></tr><tr valign="top"
align="left"><th>REMOTE_ADDR</th><td>'192.168.1.2'</td></tr><tr valign="top"
align="left"><th>HTTP_REFERER</th><td>'http://emma:8080/TEKK/portal_skins/cu
stom/main_left_column'</td></tr><tr valign="top"
align="left"><th>SERVER_NAME</th><td>'emma'</td></tr><tr valign="top"
align="left"><th>GATEWAY_INTERFACE</th><td>'CGI/1.1'</td></tr><tr
valign="top" align="left"><th>HTTP_USER_AGENT</th><td>'Mozilla/4.0
(compatible; MSIE 5.01; Windows NT 5.0)'</td></tr><tr valign="top"
align="left"><th>CONNECTION_TYPE</th><td>'Keep-Alive'</td></tr></table>,
 'root': <Application instance at 0194EEA0>,
 'template': <ZopePageTemplate instance at 015EC430>,
 'traverse_subpath': [],
 'user': Oliver})
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 158, in
__call__
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 191, in
interpret
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 503, in
do_defineMacro
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 191, in
interpret
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 345, in
do_optTag_tal
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 330, in
do_optTag
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 325, in
no_tag
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 191, in
interpret
  File C:\PROGRA~1\Emma\lib\python\TAL\TALInterpreter.py, line 402, in
do_setLocal_tal
  File C:\PROGRA~1\Emma\lib\python\Products\PageTemplates\TALES.py, line
247, in evaluate
  File C:\PROGRA~1\Emma\lib\python\Products\PageTemplates\ZRPythonExpr.py,
line 49, in __call__
    (Info: container.list_folders)
  File Python expression "container.list_folders", line 2, in f
  File C:\PROGRA~1\Emma\lib\python\AccessControl\ZopeGuards.py, line 47, in
guarded_getattr
    (Object: custom)
TALESError: (see above)


>>-----Original Message-----
>>From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Roger
>>Erens
>>Sent: 3. juli 2002 15:52
>>To: 'zope@zope.org'
>>Subject: RE: [Zope] Get all folder objects in a folder
>>
>>
>>Hi Oliver,
>>
>>could you try using a path expression
>><div tal:define="folders here/list_folders">
>>or with python
>><div tal:define="folders python: container.list_folders">
>>that is, without the parentheses?
>>
>>Regards,
>>Roger
>>
>>? -----Oorspronkelijk bericht-----
>>? Van: Oliver Marx [mailto:oliver@tekk.dk]
>>? Verzonden: woensdag 3 juli 2002 15:43
>>? Aan: Zope mailinglist
>>? Onderwerp: [Zope] Get all folder objects in a folder
>>?
>>?
>>? Hi
>>?
>>? I have a little python script:
>>?
>>? [PYTHON]
>>?
>>? """
>>? Name list_folders
>>? Returns a list of folders.
>>? """
>>?
>>? folders=container.objectValues('Folder')
>>? return folders
>>?
>>? [/PYTHON]
>>?
>>? I'm trying to call it from a ZPT
>>?
>>? [ZPT]
>>?
>>? <metal:block metal:define-macro="column">
>>?
>>? <div tal:define="folders python:here.list_folders()">
>>?
>>?   <table class="box" summary="Test" cellpadding="0" cellspacing="0">
>>?    <thead>
>>?         <tr><th>Navigation</th><th class="empty">&nbsp;</th></tr>
>>?    </thead>
>>?     <tbody>
>>?
>>?       <tr valign="top" tal:repeat="folder folders">
>>?         <td><a href="./Partners"
>>?                tal:attributes="href folder/absolute_url"
>>?                tal:content="folder/getId">Partners</a></td>
>>?       </tr>
>>?     </tbody>
>>?
>>?   </table>
>>? </div>
>>?
>>? </metal:block>
>>?
>>? [/ZPT]
>>?
>>? But it doesn't work. Zope complains about the call
>>? python:here.list_folders().
>>?
>>
>>
>>_______________________________________________
>>Zope maillist  -  Zope@zope.org
>>http://lists.zope.org/mailman/listinfo/zope
>>**   No cross posts or HTML encoding!  **
>>(Related lists -
>> http://lists.zope.org/mailman/listinfo/zope-announce
>> http://lists.zope.org/mailman/listinfo/zope-dev )
>>---
>>Incoming mail is certified Virus Free.
>>Checked by AVG anti-virus system (http://www.grisoft.com).
>>Version: 6.0.371 / Virus Database: 206 - Release Date: 13-06-2002
>>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.371 / Virus Database: 206 - Release Date: 13-06-2002