Hi,

I've tried to find a solution myself but now am stuck.  I created a little 
"Blurb" product for a university department website so that faculty members 
can announce recent publications on the department's homepage.  They create 
these ZClass instances in their own folders, and a DTML method in the 
top-level folder grabs and displays them at random.  (I want to avoid using 
ZCatalog for the time being.)  What the method does is randomly choose a 
faculty folder, and then randomly choose a Blurb instance within that 
folder.  Here's the hack I came up with:

<dtml-with Dept>
  <dtml-with Fac>
   <dtml-with Sites>
    <dtml-with "_.whrandom.choice(objectValues(['Folder']))">
     <dtml-with "_.whrandom.choice(objectValues(['Blurb']))">
      <dtml-var index_html>

(end tags omitted)

The problem is that this method will produce an Index Error when it comes 
across a folder that doesn't contain an instance of "Blurb" class.  So I 
need to make the selection of a folder conditional on Zope's finding a 
Blurb in that folder.  Here's what I tried after reading up:

<dtml-with Dept>
  <dtml-with Fac>
   <dtml-with Sites>
    <dtml-with "_.whrandom.choice(objectValues(['Folder']))">
     <dtml-if "_.has_key('Blurb')">
      <dtml-with "_.whrandom.choice(objectValues(['Blurb']))">
       <dtml-var index_html>
        </dtml-with>
         <dtml-else>
          Some default Blurb would appear.

This method fails.  Can someone help?

Cheers,
Anthony

~~~~~~~~~~~~~~~~
Anthony Brietz Monta
Coordinator of Curricular Assessment & Academic Reporting
Louisiana Board of Regents
150 Third Street, Suite 129
Baton Rouge, LA 70801-1389
225.342.4253, ext. 143
[EMAIL PROTECTED]


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to