[Zope3-Users] Re: worldcookery Christmas Dinner

2005-10-03 Thread Joel Moxley
I apologize for my replying to self, but I was re-reading Stephan's
and then Philipp's book and realized that one portion of my email has
been answered.  Thus, I'm hoping to clarify my question to the list.

Looking at the messageboard content class, I then did a grep on
Philipp's worldcookery examples directory for btree -- sure enough,
the last chapter before Expert level (14, aptly titled Containers),
addresses RecipeFolders (what I had called RecipeContainers).  It must
have been late when I read that chapter because it did not reach to
proper location in my memory :)

Bottom line, I will re-summarize my original question below with this
information in mind:

* 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
view?

Clearly, I'm still lacking some basic understanding in these areas,
and I'm going to continue to push forward, and any guidance or
suggestions of example code would be hugely appreciated.  Again,
thanks for your understanding and help.

Best,
Joel

On 10/2/05, Joel Moxley [EMAIL PROTECTED] wrote:
 Hello yall,

   I'm a python guy who wanted to provide an interface for some 
 baseball-related code to the web, so I naturally turned to Zope.  I fumbled 
 around for a while, but Philipp and Stephan's books got me on the right track.

   Philipp's book has been wonderful for learning Zope from scratch, I've read 
 and re-read the first fourteen chapters (ie, everything but Expert stuff).  
 In doing so, I created my own worldcookery-esque content management system.

   However, there are two significant holes in my knowledge that I want to 
 address: 1) integrating buttons to run controller style scripts to tabulate 
 and display statistics about multiple content objects, and 2) displaying 
 nested content objects.

   For those of yall familiar with the worldcookery scheme, I wanted to do 
 something along the lines of a Christmas Dinner.  This would be a  new 
 content object, RecipeContainer, which contains the turkey recipe, the 
 sweet potato recipe, and the cornbread recipe content objects.  You would 
 have a page template for displaying all the recipe content objects on a 
 single page (preferably with minimize/maximize capabilities), an add/remove 
 dialog for existing recipes in the database, and a button for accessing an 
 external python script to compile and display statistics (like what would be 
 the total time to prepare all dishes).

  In other words, a user might decide to also cook cornbread for Christmas 
 dinner.  Thus, the user would add a recipe for cornbread in the regular Add 
 Recipe view.  The user would then go to the ChristmasDinner RecipeContainer 
 content object where they would select the cornbread recipe object from a 
 dialog containing a list of possible recipes.  The user would then press a 
 button to access an external python script which would calculate the expected 
 time that cooking Christmas dinner with cornbread in addition to the turkey 
 and sweet potato.  This expected time (and other statistics) would be 
 displayed on the ChristmasDinner view along with the recipes.

  Right now, I'm looking at Stephan's book and the messageboard scheme to get 
 ideas (ie, message content objects inside the messageboard), but I wanted to 
 get input from yall about the best ways to do this.  I realize this will 
 probably seem obvious, but I am a true beginner in the scheme of things, and 
 I'm hoping that my experience might help extend the worldcookery teaching 
 paradigm.


   Many thanks, and go Zope 3!

  Joel
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: worldcookery Christmas Dinner

2005-10-03 Thread Duncan McGreggor


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
view?


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:

browser:page
for=myproject.containers.IRecipeFolder
name=index.html
template=recipefolderview.pt
class=.stats.Stats
permission=zope.Public /

Then,

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):


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

Hope that helps...

d

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users