On 3/30/07, Tim Hicks <[EMAIL PROTECTED]> wrote:
Does anyone see a problem with turning my custom type's listDAVObjects
method into something like this?

    def listDAVObjects(self):
        """This may have unpleasant side-effects!  Turn this into a
        generator that deactivates objects after they have been yield-ed.
        """
        for obj in self._tree.itervalues():
            yield obj.__of__(self)
            obj._p_deactivate()

I've done limited testing, and things do seem to work - both in the
sense of DAV access not breaking, and memory usage staying stable and
low.  Is this a reasonable approach, or am I destined for trouble?

IIRC you may need to test for the objects active state before
deactivating, only deactivate those that were not active in the first
place, to minimize trashing cached objects used elsewhere:

def listDAVObjects(self):
   for obj in self._tree.itervalues():
       deactivate = getattr(obj, '_p_changed', True) is None

       yield obj.__of__(self)

       if deactivate:
           obj._p_deactivate()

--
Martijn Pieters

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to