Kapil Thangavelu wrote:
> 
> Tim Cook wrote:
> 
> > -----------------------------------------------------------------------------
> >
> > Notice in add_weekly the <dtml-call day_list>.
> > It does nothing but with out it I get this traceback:
> >
> >                Zope Error
> >
> >                Zope has encountered an error while publishing
> > this resource.
> >
> >                Error Type: AttributeError
> >                Error Value: __getitem__
> >
> >
> > Traceback (innermost last):
> >   File /usr/local/zope/2.2/lib/python/ZPublisher/Publish.py, line
> 
> >     (Object: done_list)
> >   File
> > /usr/local/zope/2.2/lib/python/DocumentTemplate/DT_Util.py, line
> > 337, in eval
> >     (Object: _['sequence-item'] in day_list)
> >     (Info: day_list)
> >   File <string>, line 0, in ?
> > AttributeError: (see above)
> >
> > ------------------------------------------------------------------
> > DTML METHOD: period_begin
> > Selects a set of dates in the past 41 days that are either the
> > first day of the month or a Sunday. Returns the list.
> <snip>
> > -------------------------------------------------------
> > DTML METHOD: add_weekly
> > Input form to report weekly activities.
> >
> --------->>>>>> <dtml-call "REQUEST.set('day_list', period_begin)">
> > <dtml-call "REQUEST.set('done_list', [])">
> >
> 
> >
> > <dtml-call day_list>
> >
> > <dtml-in done_list>
> >    <dtml-if "_['sequence-item'] in day_list">
> >      <dtml-call "day_list.remove(_['sequence-item'])">
> >    </dtml-if>
> > </dtml-in>
> >
> > ....
> > more code here that uses day_list in a <SELECT></SELECT> and
> > takes more form input.
> > ...
> >
> > Is this a bug or should I clean up my code??? <s>
> >
> 
> When you call request.set your setting daylist to the method not the
> results of the method. try switching it to
> 
> <dtml-call "REQUEST.set('day_list', period_begin(_.None, _))">
> 
> Kapil
> 

Hmm, thanks.  I ran a little test stub that set day_list both
ways with the var rendered each time.  They returned exactly the
same list. 

But, your suggestion did correct the problem that I had.

So, as a newbie warning to others just because it renders
correctly doesn't mean that it's behavior is going to be correct
in a programmatic sense.  

So, why did the dtml-call or dtml-var calls cause the add_weekly
method to work?   

(Too many years of procedural code and not enough OOP zen!).

-- Tim Cook --
FreePM Project Coordinator http://www.freepm.org
OS Health Care Alliance Supporter http://www.oshca.org

_______________________________________________
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