index_object() and bobobase_modification_time with different ZCatalogs
Hello, does anybody knows a different possibility to beware the bobobase_modification_time of the given object from the following code? def my_index_object(object, catalogs=['myPointerCatalog', 'mySearchCatalog']): for cat in catalogs: object.default_catalog = cat object.index_object() # set back to default object.default_catalog = 'Catalog' regards jens
On Thu, Dec 01, 2005 at 04:44:41PM +0000, jens.walte@kk.net wrote:
Hello,
does anybody knows a different possibility to beware the bobobase_modification_time of the given object from the following code?
def my_index_object(object, catalogs=['myPointerCatalog', 'mySearchCatalog']):
for cat in catalogs: object.default_catalog = cat object.index_object()
# set back to default object.default_catalog = 'Catalog'
I don't know what "beware" means in this context. If you are asking whether it is possible to avoid changing bobobase_modification_time, the answer is no. ZODB updates bobobase_modification_time on any change to a persistent object, and there is nothing you can do to avoid this. -- Paul Winkler http://www.slinkp.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Winkler wrote:
On Thu, Dec 01, 2005 at 04:44:41PM +0000, jens.walte@kk.net wrote:
Hello,
does anybody knows a different possibility to beware the bobobase_modification_time of the given object from the following code?
def my_index_object(object, catalogs=['myPointerCatalog', 'mySearchCatalog']):
for cat in catalogs: object.default_catalog = cat object.index_object()
# set back to default object.default_catalog = 'Catalog'
I don't know what "beware" means in this context. If you are asking whether it is possible to avoid changing bobobase_modification_time, the answer is no. ZODB updates bobobase_modification_time on any change to a persistent object, and there is nothing you can do to avoid this.
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 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() Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDjzMg+gerLs4ltQ4RApzkAJ9mbsd2+gwxBH5fYl8MehHurqbzWACgss26 H1Lj6yqpVrUME1Ey06/BZCI= =8QsT -----END PGP SIGNATURE-----
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
participants (4)
-
Dieter Maurer -
jens.walte@kk.net -
Paul Winkler -
Tres Seaver