RE: [Zope-dev] Computed fields in ZCatalog
From: Kevin Dangoor [mailto:kid@kendermedia.com]
Looking at the ZCatalog code, if an index or metadata field is callable for a particular object, then that function will be called. However, it isn't called with *any* parameters. Is there any way to make that metadata value based upon other values in the object?
For example, if I wanted to create a method that would return Property1+Property2 and have that value show up in the Catalog, can that be done?
Only with methods that don't need any arguments, like an External Method. DTML Methods required arguments, so they will not do. -- Martijn Pieters, Software Engineer | Digital Creations http://www.digicool.com | Creators of Zope http://www.zope.org | mailto:mj@digicool.com ICQ: 4532236 | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 -------------------------------------------
Martijn Pieters wrote:
For example, if I wanted to create a method that would return Property1+Property2 and have that value show up in the Catalog, can that be done?
Only with methods that don't need any arguments, like an External Method. DTML Methods required arguments, so they will not do.
In other words, use PythonMethods. They are exectly what you need for this kind of thing. parameters: self body: return self.Property1 + self.Property2 -- Itamar S.T. itamars@ibm.net
----- Original Message ----- From: "Itamar Shtull-Trauring" <itamars@ibm.net> To: <zope-dev@zope.org> Sent: Sunday, February 13, 2000 5:44 AM Subject: Re: [Zope-dev] Computed fields in ZCatalog
Martijn Pieters wrote:
For example, if I wanted to create a method that would return Property1+Property2 and have that value show up in the Catalog, can that be done?
Only with methods that don't need any arguments, like an External Method. DTML Methods required arguments, so they will not do.
In other words, use PythonMethods. They are exectly what you need for this kind of thing.
parameters: self body: return self.Property1 + self.Property2
You know what's funny is that I could swear I tried this. I set up a little test today, though, and sure enough it worked! Not sure what I did wrong in my previous tests, but I'll just be happy to have this working. Kevin
participants (3)
-
Itamar Shtull-Trauring -
Kevin Dangoor -
Martijn Pieters