[Zope] Calling the del function from a DTML document/method
Chris Withers
chris at simplistix.co.uk
Fri Jun 4 05:07:19 EDT 2004
Jonathan Cyr wrote:
> <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')">
For gods sake, do this in a python script!
cutoff = DateTime()-45
for file in context.Files.objectValues('File'):
if file.bobobase_modification_time()<=cutoff:
context.Files.manage_delObjects([file.getId()])
return context.filelist_html()
or, more compactly:
cutoff = DateTime()-45
context.Files.manage_delObjects(
[file.getId() for file in context.Files.objectValues('File')
if file.bobobase_modification_time()<=cutoff ]
)
return context.filelist_html()
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope
mailing list