Greetings. I need to use ZCatalog to index computed values of my ZClass. It seems that ZCatalog will happily call DTML methods and index their output, but the DTML methods are not called with any arguments so cannot do very much. At the moment, I'm having to shadow the output of my DTML methods (eg. return the Id of PARENTS[1] type stuff) in property sheets to achieve the required functionality, but this is ugly. Is this sort of thing possible with ZClasses, or is this where it is worth switching to Python classes? Would it be possible to modify Catalog to do this? I think the necessary section to modify would be recordify in Catalog.py. The first argument to a DTML Method call would just be the object passed to recordify. I'm unsure how to fake up the REQUEST attribute though. Is this the right way to proceed? ___ // Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au // E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au //__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen
Stuart 'Zen' Bishop wrote:
Greetings.
I need to use ZCatalog to index computed values of my ZClass. It seems that ZCatalog will happily call DTML methods and index their output, but the DTML methods are not called with any arguments so cannot do very much.
Right.
At the moment, I'm having to shadow the output of my DTML methods (eg. return the Id of PARENTS[1] type stuff) in property sheets to achieve the required functionality, but this is ugly.
Yup.
Is this sort of thing possible with ZClasses, or is this where it is worth switching to Python classes?
You might want to step down to Python, especially for 'computable' like stuff.
Would it be possible to modify Catalog to do this? I think the necessary section to modify would be recordify in Catalog.py. The first argument to a DTML Method call would just be the object passed to recordify. I'm unsure how to fake up the REQUEST attribute though. Is this the right way to proceed?
The problem here is that an assumption is being made, passing an object in as the first argument to a bound method. The whole argument passing concept in general is ripe with complication, as everyone and their brother is going to want to call a method their way, although I do agree that calling DTML methods with a context is useful. I'll have to think about this a bit to see if there is a general solution, in the mean time you can of course modify your code (you found the right spot). Anyone else have any ideas? -Michel
On Sun, 17 Oct 1999, Michel Pelletier wrote:
Would it be possible to modify Catalog to do this? I think the necessary section to modify would be recordify in Catalog.py. The first argument to a DTML Method call would just be the object passed to recordify. I'm unsure how to fake up the REQUEST attribute though. Is this the right way to proceed?
The problem here is that an assumption is being made, passing an object in as the first argument to a bound method. The whole argument passing concept in general is ripe with complication, as everyone and their brother is going to want to call a method their way, although I do agree that calling DTML methods with a context is useful.
I'll have to think about this a bit to see if there is a general solution, in the mean time you can of course modify your code (you found the right spot). Anyone else have any ideas?
How does the following sound for a solution?: Each index and column in the ZCatalog has three variables - name, type and expression. Name and type are as they already are. If expression is empty, then behaviour works exactly like it does now. If expression is not empty, it is passed to the object for evaluation, along with a fake REQUEST object and whatever else is deemed necessary. This method would have to be added to Base or similar base class if there is currently no way of doing this. eg. expr = title expr = myMethod(this(),REQUEST) expr = id + ': ' + title expr = absolute_url() Slight modification to this might be: Only evaluate the expression if the object does not have an attribute matching the index name or Only evaluate the expression if the object does not have a non callable attribute matching the index name or Only evaluate the expression if the object does not have an attribute matching the index name, or this attribute returned a false value or threw an exception. The last option would allow me to provide a fallback if a given attribute is not set (eg. an index [summary, TextIndex, "id + title"] or [summary, TextIndex, "text[:256]"] or [summary, TextIndex, "buildSummary()"] ___ // Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au // E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au //__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen
participants (2)
-
Michel Pelletier -
Stuart 'Zen' Bishop