RE: [Zope] Help using list within python method
[Michael Long]
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.
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:
[snip]
Module Products.dlAddressBook.AddressBook, line 182, in listEntriesByGroup TypeError: 'in <string>' requires character as left operand
Your test if groups == "All" must always fail if no argument is passed in(since the default argument is a list, not a string) or if the argument is a string. If so, you will always execute the "else" at line 180, where the traceback says the error is.. Now if groups is really a string and entry.Group is not a string, that would cause the error. So you had best check to see what type of critter you are using there. Are you sure you did not mean to make use of EntryID somewhere? Cheers, Tom P
participants (1)
-
Passin, Tom