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):
     ... similar for the other indexing related method ...

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

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to