[Zope] ZPT: How do I see if something is in a sequence?

alan runyan alan runyan" <runyaga@runyaga.com
Tue, 14 Aug 2001 23:50:25 -0500


> Unless you've already used tal:define to create a 'member' variable, you
> probably want one of these:
>
> tal:condition="python:'different' in here.member.hl_roles"
> tal:condition="python:'different' in container.member.hl_roles"

this does not work:

<select name="moderator_ids:list" size="5" multiple>
                 <option tal:repeat="member
container/portal_membership/listMembers"
                         tal:condition="python:'Moderator' in
here.member.helplink_roles"
                         tal:content="python:member.getUserName()"> memberid
</option>
               </select>

but this displays everyones helplink_roles sequence:

<select name="moderator_ids:list" size="5" multiple>
                 <option tal:repeat="member
container/portal_membership/listMembers"
                         tal:content="python:member.helplink_roles">
memberid </option>
               </select>


I've tried tal:condition="python:'Moderator' in here(repeat, request,
container).member.helplink_roles"

inside the () are the attempted replacement for here.  I am having no luck?
am I doing something very wrong?  this seems like it should work.
desperately, ~runyaga

 here is the traceback:

Traceback (innermost last):
  File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 223, in
publish_module
  File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File C:\PROGRA~1\WebSite\lib\python\Zope\__init__.py, line 226, in
zpublisher_exception_hook
    (Object: LockableItem)
  File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 171, in
publish
  File C:\PROGRA~1\WebSite\lib\python\ZPublisher\mapply.py, line 160, in
mapply
    (Object: assign_helplink_roles)
  File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 112, in
call_object
    (Object: assign_helplink_roles)
  File C:\PROGRA~1\WebSite\lib\python\Shared\DC\Scripts\Bindings.py, line
324, in __call__
    (Object: assign_helplink_roles)
  File C:\PROGRA~1\WebSite\lib\python\Shared\DC\Scripts\Bindings.py, line
354, in _bindAndExec
    (Object: assign_helplink_roles)
  File C:\Program
Files\WebSite\lib\python\Products\PageTemplates\ZopePageTemplate.py, line
265, in _exec
    (Object: assign_helplink_roles)
  File C:\Program
Files\WebSite\lib\python\Products\PageTemplates\PageTemplate.py, line 156,
in pt_render
    (Object: assign_helplink_roles)
    (Info: {'container': <Folder instance at 01B458A8>,
 'here': <Folder instance at 01B458A8>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter
instance at 0148D7DC>,
 'nothing': None,
 'options': {'args': ()},
 'request': <h3>form</h3><table></table><h3>cookies</h3><table><tr
valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW3UdhWiEiFdOMbpIrgG6SJ6rrXosFAA
AF30UyQ'</td></tr><tr valign="top"
align="left"><th>__ac_name</th><td>'runyaga'</td></tr><tr valign="top"
align="left"><th>__ac</th><td>'cnVueWFnYToxMjM%3D%0A'</td></tr><tr
valign="top" align="left"><th>portal_skin</th><td>'Basic'</td></tr><tr
valign="top"
align="left"><th>show_filter_form</th><td>'1'</td></tr></table><h3>other</h3
><table><tr valign="top"
align="left"><th>BASE4</th><td>'http://localhost/site/portal_skins/custom'</
td></tr><tr valign="top"
align="left"><th>portal_skin</th><td>'Basic'</td></tr><tr valign="top"
align="left"><th>show_filter_form</th><td>'1'</td></tr><tr valign="top"
align="left"><th>BASE3</th><td>'http://localhost/site/portal_skins'</td></tr
><tr valign="top" align="left"><th>__ac_name</th><td>'runyaga'</td></tr><tr
valign="top" align="left"><th>BASE1</th><td>'http://localhost'</td></tr><tr
valign="top" align="left"><th>traverse_subpath</th><td>[]</td></tr><tr
valign="top"
align="left"><th>SERVER_URL</th><td>'http://localhost'</td></tr><tr
valign="top"
align="left"><th>AUTHENTICATED_USER</th><td>runyaga</td></tr><tr
valign="top"
align="left"><th>TraversalRequestNameStack</th><td>[]</td></tr><tr
valign="top"
align="left"><th>BASE6</th><td>'http://localhost/site/portal_skins/custom/he
lplink/assign_helplink_roles'</td></tr><tr valign="top"
align="left"><th>BASE5</th><td>'http://localhost/site/portal_skins/custom/he
lplink'</td></tr><tr valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW3UdhWiEiFdOMbpIrgG6SJ6rrXosFAA
AF30UyQ'</td></tr><tr valign="top"
align="left"><th>AUTHENTICATION_PATH</th><td>'site'</td></tr><tr
valign="top"
align="left"><th>URL3</th><td>'http://localhost/site/portal_skins'</td></tr>
<tr valign="top"
align="left"><th>URL0</th><td>'http://localhost/site/portal_skins/custom/hel
plink/assign_helplink_roles'</td></tr><tr valign="top"
align="left"><th>URL1</th><td>'http://localhost/site/portal_skins/custom/hel
plink'</td></tr><tr valign="top"
align="left"><th>__ac</th><td>'cnVueWFnYToxMjM%3D%0A'</td></tr><tr
valign="top"
align="left"><th>URL4</th><td>'http://localhost/site'</td></tr><tr
valign="top" align="left"><th>URL5</th><td>'http://localhost'</td></tr><tr
valign="top"
align="left"><th>URL2</th><td>'http://localhost/site/portal_skins/custom'</t
d></tr><tr valign="top"
align="left"><th>PUBLISHED</th><td>&lt;ZopePageTemplate instance at
01C10600&gt;</td></tr><tr valign="top"
align="left"><th>URL</th><td>'http://localhost/site/portal_skins/custom/help
link/assign_helplink_roles'</td></tr><tr valign="top"
align="left"><th>BASE2</th><td>'http://localhost/site'</td></tr><tr
valign="top" align="left"><th>BASE0</th><td>'http://localhost'</td></tr><tr
valign="top"
align="left"><th>URL0</th><td>http://localhost/site/portal_skins/custom/help
link/assign_helplink_roles</td></tr><tr valign="top"
align="left"><th>URL1</th><td>http://localhost/site/portal_skins/custom/help
link</td></tr><tr valign="top"
align="left"><th>URL2</th><td>http://localhost/site/portal_skins/custom</td>
</tr><tr valign="top"
align="left"><th>URL3</th><td>http://localhost/site/portal_skins</td></tr><t
r valign="top"
align="left"><th>URL4</th><td>http://localhost/site</td></tr><tr
valign="top" align="left"><th>URL5</th><td>http://localhost</td></tr><tr
valign="top" align="left"><th>BASE0</th><td>http://localhost</td></tr><tr
valign="top" align="left"><th>BASE1</th><td>http://localhost</td></tr><tr
valign="top"
align="left"><th>BASE2</th><td>http://localhost/site</td></tr><tr
valign="top"
align="left"><th>BASE3</th><td>http://localhost/site/portal_skins</td></tr><
tr valign="top"
align="left"><th>BASE4</th><td>http://localhost/site/portal_skins/custom</td
></tr><tr valign="top"
align="left"><th>BASE5</th><td>http://localhost/site/portal_skins/custom/hel
plink</td></tr><tr valign="top"
align="left"><th>BASE6</th><td>http://localhost/site/portal_skins/custom/hel
plink/assign_helplink_roles</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>997850492</td></tr><tr
valign="top" align="left"><th>SERVER_PROTOCOL</th><td>'1.1'</td></tr><tr
valign="top" align="left"><th>SERVER_PORT</th><td>'80'</td></tr><tr
valign="top"
align="left"><th>PATH_INFO</th><td>'/site/portal_skins/custom/helplink/assig
n_helplink_roles'</td></tr><tr valign="top"
align="left"><th>HTTP_HOST</th><td>'localhost'</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>'\\site\\portal_skins\\custom\\help
link\\assign_helplink_roles'</td></tr><tr valign="top"
align="left"><th>HTTP_COOKIE</th><td>'__ac_name="runyaga";
show_filter_form="1"; portal_skin="Basic"; __ac="cnVueWFnYToxMjM%3D%0A";
tree-s="eJyLjlZ3hANPW3UdhWiEiFdOMbpIrgG6SJ6rrXosFAAAF30UyQ"'</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.4.0
(binary release, python 2.1, win32-x86), python 2.1.0, win32)
ZServer/1.1b1'</td></tr><tr valign="top"
align="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>'en-us'</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>'127.0.0.1'</td></tr><tr valign="top"
align="left"><th>HTTP_REFERER</th><td>'http://localhost/site/portal_skins/cu
stom/helplink/assign_helplink_roles'</td></tr><tr valign="top"
align="left"><th>SERVER_NAME</th><td>'pythonic'</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.5; 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 019BD8E0>,
 'template': <ZopePageTemplate instance at 01C10600>,
 'traverse_subpath': [],
 'user': runyaga})
  File C:\Program Files\WebSite\lib\python\TAL\TALInterpreter.py, line 232,
in __call__
  File C:\Program Files\WebSite\lib\python\TAL\TALInterpreter.py, line 265,
in interpret
  File C:\Program Files\WebSite\lib\python\TAL\TALInterpreter.py, line 590,
in do_condition
  File C:\Program Files\WebSite\lib\python\Products\PageTemplates\TALES.py,
line 301, in evaluateBoolean
  File C:\Program Files\WebSite\lib\python\Products\PageTemplates\TALES.py,
line 286, in evaluate
  File C:\Program
Files\WebSite\lib\python\Products\PageTemplates\ZRPythonExpr.py, line 121,
in __call__
    (Info: 'Moderator' in here.member.helplink_roles)
  File Python expression "'Moderator' in here.member.helplink_roles", line
2, in f
    (Object: guarded_getattr)
  File C:\PROGRA~1\WebSite\lib\python\AccessControl\ZopeGuards.py, line 109,
in guarded_getattr
    (Object: LockableItem)
TALESError: (see above)