[Zope] Help using list within python method

Michael Long mlong@datalong.com
Fri, 21 Mar 2003 15:48:45 -0500


I have a method that is returning an error that I have not been able to
resolve. I have tried to duplicate the error in python to no avail. I am
sure the solution is very simple I just don't see it.

tia,
Mike

 Here is the method:

    172         def listEntriesByGroup(self, groups=["All"]):
    173                 "Method to list Entries"
    174                 ret=[]
    175                 if type(groups) != ListType:
    176                         EntryIDs = [groups]
    177                 if groups == "All":
    178                         for entry in self.Entries.values():
    179                                 ret.append(entry)
    180                 else:
    181                         for entry in self.Entries.values():
    182                                 if entry.Group in groups:
    183                                         ret.append(entry)
    184                 return ret

The traceback is:

Traceback (innermost last):
  Module ZPublisher.Publish, line 98, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Products.dlAddressBook.AddressBook, line 134, in index_html
  Module Shared.DC.Scripts.Bindings, line 252, in __call__
  Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 96, in _exec
  Module Products.PageTemplates.PageTemplate, line 95, in pt_render
   - <PageTemplateFile at /TEST/test/>
  Module TAL.TALInterpreter, line 186, in __call__
  Module TAL.TALInterpreter, line 230, in interpret
  Module TAL.TALInterpreter, line 689, in do_useMacro
  Module TAL.TALInterpreter, line 230, in interpret
  Module TAL.TALInterpreter, line 712, in do_defineSlot
  Module TAL.TALInterpreter, line 230, in interpret
  Module TAL.TALInterpreter, line 578, in do_insertStructure_tal
  Module Products.PageTemplates.TALES, line 217, in evaluate
   - URL: main_page
   - Line 14, Column 16
   - Expression: standard:'here/content'
   - Names:
      {'container': <AddressBook at /TEST/test>,
       'default': <Products.PageTemplates.TALES.Default instance at
0x868e42c>,
       'here': <AddressBook at /TEST/test>,
       'loop': <SafeMapping instance at 84c75e0>,
       'modules':
<Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at
0x86b2b7c>,
       'nothing': None,
       'options': {'args': (<AddressBook at /TEST/test>,
                            <HTTPRequest,
URL=http://zeus:8080/TEST/test/index_html>)},
       'repeat': <SafeMapping instance at 84c75e0>,
       'request': <HTTPRequest, URL=http://zeus:8080/TEST/test/index_html>,
       'root': <Application instance at 9643db0>,
       'template': <PageTemplateFile at /TEST/test/>,
       'traverse_subpath': [],
       'user': admin}
  Module Products.PageTemplates.Expressions, line 206, in __call__
  Module Products.PageTemplates.Expressions, line 201, in _eval
  Module Products.PageTemplates.Expressions, line 100, in render
  Module Products.PageTemplates.ZRPythonExpr, line 74, in call_with_ns
  Module Shared.DC.Scripts.Bindings, line 266, in __render_with_namespace__
  Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 96, in _exec
  Module Products.PageTemplates.PageTemplate, line 95, in pt_render
   - <PageTemplateFile at /TEST/test/>
  Module TAL.TALInterpreter, line 186, in __call__
  Module TAL.TALInterpreter, line 230, in interpret
  Module TAL.TALInterpreter, line 459, in do_setLocal_tal
  Module Products.PageTemplates.TALES, line 217, in evaluate
   - URL: indexAddressBook
   - Line 1, Column 0
   - Expression: <PythonExpr here.listEntriesByGroup(SelectedGroup)>
   - Names:
      {'container': <AddressBook at /TEST/test>,
       'default': <Products.PageTemplates.TALES.Default instance at
0x868e42c>,
       'here': <AddressBook at /TEST/test>,
       'loop': <SafeMapping instance at 90ae240>,
       'modules':
<Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at
0x86b2b7c>,
       'nothing': None,
       'options': {'args': ()},
       'repeat': <SafeMapping instance at 90ae240>,
       'request': <HTTPRequest, URL=http://zeus:8080/TEST/test/index_html>,
       'root': <Application instance at 9643db0>,
       'template': <PageTemplateFile at /TEST/test/>,
       'traverse_subpath': [],
       'user': admin}
  Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__
   - __traceback_info__: here.listEntriesByGroup(SelectedGroup)
  Module Python expression "here.listEntriesByGroup(SelectedGroup)",
line 2, in f
  Module Products.dlAddressBook.AddressBook, line 182, in listEntriesByGroup
TypeError: 'in <string>' requires character as left operand