[Zope] DTML Method - delete files

Jonathan Cyr cyrj at cyr.info
Mon May 17 15:58:36 EDT 2004


Hi,

I just needed the same thing... here another way.

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



Ausum Studio wrote:

>Look for the object DateTime in the help files of your Zope installation.
>They have a nice set of methods to compare time dates.
>
>Anyways, they all return false or true, so in your case I would convert the
>time dates to integers, then perform a simple subtraction operation, and
>check if the most recent date is greater to ...
>seconds_in_a_day * 5.
>
>Ausum
>
>
>----- Original Message ----- 
>From: "Laura McCord" <Laura.McCord at doucet-austin.com>
>To: <zope at zope.org>
>Sent: Friday, May 14, 2004 4:10 PM
>Subject: [Zope] DTML Method - delete files
>
>
>I am almost done writing the script but I need to figure out how to
>compare two dates. For instance, I have this: <dtml-var ZopeTime
>fmt="%m/%d/%Y">
>                                  <dtml-var modification_date
>fmt="%m/%d/%Y">
>
>*** Now I need to compare the two dates to see if the ZopeTime is
>greater by 5 days.
>
>Any ideas on how to do that using dtml?
>
>_______________________________________________
>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 )
>
>_______________________________________________
>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 )
>
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20040517/bf01d5ee/attachment.html


More information about the Zope mailing list