[Zope] Re: Automatically adding properties (keywords) to folders
tseaver at palladion.com
Thu Apr 20 13:07:44 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Terry Jones wrote:
> I'd like to set up a folder in Zope with the property that when an object
> is put into it, the object has a keyword added to it automatically (and
> when the object is moved out of the folder, the keyword is removed).
> If you could do this, you would have a nice way to maintain a collection of
> such folders and have their contents appear elsewhere in a collection of
> Plone Smart Folders (using keyword criteria).
> Can anyone tell me how I should best go about doing this?
> I can imagine writing some python to run once in a while, find all the
> contents of the folder, add the keywords, etc. But that's far from being an
> ideal solution.
> Any pointers would be much appreciated.
The old way to do that we be to derive your own folder class and
override '_setObject' / '_delObject' to add your semantics.
The new way (for Zope >= 2.9) would be to register a subscriber for the
"container" events which are published automatically. Something like
keyword = getattr(event.newparent, 'keyword', None)
event.object.keyword = None
and then in ZCML::
Tres Seaver +1 202-558-7113 tseaver at 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
-----END PGP SIGNATURE-----
More information about the Zope