[Zope] Re: Automatically adding properties (keywords) to folders
Tres Seaver
tseaver at palladion.com
Thu Apr 20 16:42:27 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Terry Jones wrote:
> Hi Tres
>
> Thanks for your answer. Could I trouble you a little bit more please?
>
> I don't know where I'd put these fragments (and the last one seems
> incomplete, perhaps intentionally?). I'm happy to read and code myself, so
> I don't mean to ask for much here, but I'm not sure what to do with your
> suggestion. I read version 2.6 of the zope book, and today found out
> there's a proto-version 2.7, which I'll take a look at.
Note that the "new way" stuff is only for Zope *later* than 2.8.x.
In that case, you would define the function in a module somewhere on
your $PYTHONPATH (e.g., in $INSTANCE_HOME/lib/python, or in a product)
and then register it in a ZCML file which is included from your
'site.zcml' (in $INSTANCE_HOME/etc).
> Anyway, thanks again.
>
> Terry
>
> | 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
> | (untested)::
> |
> | def update_keywords(event):
> | keyword = getattr(event.newparent, 'keyword', None)
> | event.object.keyword = None
> | event.object.reindexObject()
> |
> | and then in ZCML::
> |
> | <subscriber
> | for="zope.app.event.objectevent.ObjectEvent"
> | factory="Products.yourproduct.events.update_keywords"
Tres.
- --
===================================================================
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
iD8DBQFER/Iq+gerLs4ltQ4RAvSAAJ9edkh96NO63lrKF6mkuDeAGYSYWQCgp98g
hp/tu+8LtZFYjJvX3rSxuao=
=m3sh
-----END PGP SIGNATURE-----
--
===================================================================
Tres Seaver +1 202-558-7113 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
More information about the Zope
mailing list