[Zope-dev] Re: brain.getObject and traversal

Max M maxm at mxm.dk
Thu Mar 31 07:48:54 EST 2005


Chris Withers wrote:

> Well, in 2.8, new behaviour is expected, right?
> I really passionately believe that we should not be returnining None in 
> Zope 2.8, and since 2.8 hasn't quite hit beta yet I'm very keen to see 
> it fixed asap.
> 
> Any objections?

Most of my queries, where I need to wake up objects, has the form::

     brains = catalog(portal_type='Document')
     objects = []
     for brain in brains:
         try:
             obj = brain.getObject()
             if not obj is None:
                 objects.append(obj)
         except:
             pass

So it will not break any of my code, and I guess that most do something
similar.



Another thing is that I think that this pattern is so common that the
catalog should have a query method where brains are automatically
converted to objects. Like:

     objects = catalog.getObjects(portal_type='Document')

That would be a handy time saver.

-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science



More information about the Zope-Dev mailing list