[Zope] Help: simple python method goes wrong

Maik Jablonski maik.jablonski@uni-bielefeld.de
05 Jun 2002 12:11:49 +0200


On Wed, 2002-06-05 at 10:39, Julian Knight wrote:
> I have a Python method as follows:
> 
> 
> results=[]
> for object in context.objectValues('DTML Document'):
>   results=results.append(object)
> return results
> 
> 
> Calling this (from the test tab) results in: 
> 
> Error Type: AttributeError
> Error Value: 'None' object has no attribute 'append'
> 
> And yet this is the same as the example on page 170/171 of the Zope
> book!

hi,

you're wrong... ZopeBook is a little bit different:

 results=[]
 for object in context.objectValues('DTML Document'):
   results.append(object)   <= Change this line!!!
 return results

reason: results.append(object) returns None, but appends a object to
results!

greetings, maik
-- 
maik jablonski             \   -;~~;-   /                 www.dzug.org
universitaet bielefeld      >   (@@)   <      www.zfl.uni-bielefeld.de
zentrum fuer lehrerbildung / RUN <> GNU \ www.sachunterricht-online.de