[Zope] Calling list.remove() bug

Tim Cook twcook@iswt.com
Sun, 27 Aug 2000 15:21:41 -0500


Platform information:

Zope version: Zope 2.2.1b1 (binary release, python 1.5.2,
linux2-x86) 
Python version: 1.5.2 (#10, Dec 6 1999, 12:16:27) [GCC 2.7.2.3] 
System Platform: linux2 

-----------------------------------------------------------------------------

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
222, in publish_module
  File /usr/local/zope/2.2/lib/python/ZPublisher/Publish.py, line
187, in publish
  File /usr/local/zope/2.2/lib/python/Zope/__init__.py, line 221,
in zpublisher_exception_hook
    (Object: Traversable)
  File /usr/local/zope/2.2/lib/python/ZPublisher/Publish.py, line
171, in publish
  File /usr/local/zope/2.2/lib/python/ZPublisher/mapply.py, line
160, in mapply
    (Object: add_weekly)
  File /usr/local/zope/2.2/lib/python/ZPublisher/Publish.py, line
112, in call_object
    (Object: add_weekly)
  File /usr/local/zope/2.2/lib/python/OFS/DTMLMethod.py, line
172, in __call__
    (Object: add_weekly)
  File
/usr/local/zope/2.2/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
    (Object: add_weekly)
  File /usr/local/zope/2.2/lib/python/DocumentTemplate/DT_In.py,
line 691, in renderwob
    (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.

<dtml-call "REQUEST.set('first_day', ZopeTime() )">
<dtml-call "REQUEST.set('to_day', ZopeTime() )">
<dtml-call "REQUEST.set('day_list', [])">

  <dtml-in "_.range(0,40)">
    <dtml-call "REQUEST.set('rpt_date', first_day -
_['sequence-item'])">

     <dtml-if "rpt_date.lessThanEqualTo( to_day )">
       <dtml-if "(rpt_date.day()==1) or rpt_date.dow()==0">
          <dtml-call "day_list.append(rpt_date.strftime('%Y / %m
/ %d'))">
       </dtml-if>
     </dtml-if>

  </dtml-in>

<dtml-return day_list>

-------------------------------------------------------
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-in "objectValues(['DTML Document'])">
  <dtml-if "doc_type == 'weekly'">
     <dtml-call "done_list.append(week_begin.strftime('%Y / %m /
%d'))">
  </dtml-if>
</dtml-in>

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


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