[Zope] Re: index_object() and bobobase_modification_time with different ZCatalogs

Dieter Maurer dieter at handshake.de
Fri Dec 2 14:59:17 EST 2005


Tres Seaver wrote at 2005-12-1 12:30 -0500:
> ...
>Hmmm, I wonder if one could hack it by avoiding '__setattr__', e.g.:
>
>   for cat in catalogs:
>       object.__dict__['default_catalog'] = cat
>       object.index_object()
>
>   cat._p_deactivate() # throw away changes

You probably mean "object._p_deactivate()".

This will not work when "object" was modified before.

>But why don't we avoid the whole thing and just call the catalog directly:
>
>   for cat in catalogs:
>       cat.catalog_object(object, object.url()

Usually, "object" will not have an "url" method (or attribute).
Apart from that, this is a very good idea.

An alternative could be the use of a wrapper:

   from ExtensionClass import Base

   class _Wrapper(Base):
     def __init__(cat, obj):
       self.default_catalog = cat
       self.__obj = obj

     def indexObject(self):
       self.__obj.indexObject.im_func(self)
     ... similar for the other indexing related method ...

     def __getattr__(self, key): return getattr(self.__obj, key)

-- 
Dieter


More information about the Zope mailing list