Hello, You said:
/ I want to do queries like: /> >/ "Who are the managers that look over Golden Delicious Fields?" /> >/ "What kinds of apples are grown in the Valley Orchard?" /> >/ /> >/ Currently, I am trying to do a zcatalog query for the known item (say, /> >/ the Orchard) and then run up or down the acquisition chain to retrieve /> >/ the unknown, but related quantity. /> >/ /> >/ Is there an easier way to do this? One of the things that I like about /> >/ Zope is the ability to store objects in their natural hierarchies. Can /> >/ I use that to get information about objects that are related to my /> >/ current object? /> >/ /> >/ Thanks, /> >/ /> >/ VanL /> have a look at ZCatalogs-PathIndex... with some python-logic you should be able to do this kind of questions.
I have been trying to do figure it out with the path, but I am still not able to. Any suggestions or sample code? Thanks, VanL
VanL wrote:
/> >/ "Who are the managers that look over Golden Delicious Fields?" /> >/ "What kinds of apples are grown in the Valley Orchard?" /> >/ /> >/ Currently, I am trying to do a zcatalog query for the known item (say, /> >/ the Orchard) and then run up or down the acquisition chain to retrieve /> >/ the unknown, but related quantity. /> >/ /> >/ Is there an easier way to do this? One of the things that I like about /> >/ Zope is the ability to store objects in their natural hierarchies. Can /> >/ I use that to get information about objects that are related to my /> >/ current object?
You could just create a unique method in ie. the manager class and call it something like "getmanager()" which returns self. It's a trick I have used once in a while. def getmanager(): return context.this() Hmmm i usually only work in Python products so this is probably a little off. then you just call getmanager() on the object from the Catalog and aquisition takes care of the rest. regards Max M "Skeptic Effect" or the "Randi Effect" When a skeptic is near, supernatural effects seem to disappear.
Thanks, I am trying your method. I have defined in my python products 'get_Field()', 'get_Orchard()', 'get_Manager(''), etc. These functions return the associated object. However, when I try to run these, I get an error: The calling form looks like this: <dtml-in expr="DTMLQuery(search=REQUEST.form)"> <dtml-var sequence-item> <dtml-in> DTMLQuery is bombing out on the following function: def doAQ(resultlist): if control['relation'] == 'self': return resultlist else: aqresults = [] if control['relation'] == 'manager': for res in resultlist: aqresults.append(res.get_Manager()) else: assert control['relation'] == 'field' for res in resultlist: aqresults.append(res.get_Field()) return aqresults This is called friom the line: return doAQ(doQuery(postProcess(search))) I also tried this with list comprehensions, and got the same result (just in case I was doing something boneheaded) I have confirmed that the query works, and the get_Manager (etc) functions have worked in a different context. Rather, Zope gives the following error message: *Error Type: RuntimeError* *Error Value: function attributes not accessible in restricted mode Zope gives this message as soon as I try to access the member functions for the types I have defined. I'm confused abo*ut the error message; I'm not trying to access a function attribute, AFAIK. Rather, this is a class function. Any help? Thanks, VanL
participants (2)
-
Max M -
VanL