[Zope] Calling the del function from a DTML document/method

Jonathan Cyr cyrj at cyr.info
Thu Jun 3 19:18:08 EDT 2004


Hi,

I just needed the same thing... I had difficulty finding the answer. 
Here's my solution, I hope its helpful.

Deleting Zope Objects in DTML based on timestamp.

I created this for housekeeping of a file repository,very similar the 
the File Library app in the Zope Examples.  This dtml-method deletes 
items of type "File" that haven't been modified in 45 days.

Notice the syntax in the line:      <dtml-call 
expr="manage_delObjects([_['id'],])">

I Google'd it, apparently its handing manage_delObjects a list of one 
item, and that item is the item "id" from the current namespace.  The 
trailing comma is for a list of one item.

To test it, I commented the manage_delObjects line, and included the 
commented lines below, to test for the correct results.


<dtml-with Files>
<dtml-in expr="objectItems('File')" sort="bobobase_modification_time" 
reverse>
<dtml-with sequence-item>
    <dtml-if expr="bobobase_modification_time()<=ZopeTime()-45">
      <!-- DEL: <dtml-var absolute_url><br> -->
      <dtml-call expr="manage_delObjects([_['id'],])">
    <dtml-else>
      <!-- KEEP: <dtml-var absolute_url><br> -->
    </dtml-if>
   </dtml-with>
</dtml-in>
</dtml-with>
<dtml-call "RESPONSE.redirect('filelist_html')">

Good Luck,

-Jonathan Cyr

Asad Habib wrote:

> Hello. Is it possible to call the del function(this deletes
> single/multiple items from a list) from a DTML document/method. If so,
> what is the correct syntax for this? Thanks.
> 
> - Asad
> 
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
> 



More information about the Zope mailing list