On Oct 3, 2005, at 12:32 AM, Joel Moxley wrote:

* RecipeFolder Views.  In a RecipeFolder page template file, how would
you view both parameters on the parent RecipeFolder as well as
specific child Recipes within the container?

* RecipeFolder Controllers.  How would you access an external python
method for compiling statistics on this container and then update the

I think for both of these, what you're looking for is the catalog. It might mean writing your own custom index, based on your needs... (but you should be able to at least prototype it with just the field and text indices that are a part of the catalog by default). If, with your content objects, you are storing or annotating the data you want to analyze, you'll just need to add indices in your site catalog for those schema fields/attributes.

For your first bullet item above... hmm, maybe catalog + checking for children? Never done anything directly with the children of a particular container before.

For the second one, I think just catalog should do the trick.

What I'd do is

1) create a class in browser (e.g., myproject.browser.stats.Stats) where in I write the catalog queries. I put mine in browser because I mentally associate my queries with displaying data with page templates. Arguably, they might be better the next level up, since data queries really should be agnostic as to the final medium (http, webdav, ftp, etc.). For every type of processed stats I would want, I'd write a method in the Stats class. As Alen and I discussed in a recent thread, perhaps something like

from zope.app.publisher.browser import BrowserView
from zope.app.catalog.interfaces import ICatalog
from zope.app import zapi

class Stats(BrowserView):
    def getParentAndChildStats(self):
        catalog = zapi.getUtility(ICatalog)
results = catalog.searchResults(index_name_for_field=[some, list, of, criteria])
        # process your results
# do child checks? efficiency issues? I'm sure there's a better way...

My queries are typically associated with a particular content type (as it sounds like yours will be... particularly RecipeFolder). So then I'd

2) add something like this to the browser/configure.zcml file:

        permission="zope.Public" />


3) use "view/method_name" in your page templates to access the the Stats methods you wrote. Data presentation gets messy in HTML/ZPT, so I typically separate that out into a macro so I can keep my *view.pt files clean. You'd have something like this in your recipefolderview.pt (or macro that recipefolderview.pt calls):

<tal:stats repeat="stat view/getParentAndChildStats">
  <!-- display stat and/or its attributes /-->

Hope that helps...


Zope3-users mailing list

Reply via email to