[Zope] expiring dtml documents
wade naveja
wade@fizzylab.com
Tue, 21 Nov 2000 10:56:17 -0800 (PST)
this is great! i'll give this - or something similar - a try in the near
future.
in know that zope has a reputation for less than cohesive documentation,
but can someone point me in the direction of some zope api documentation?
On Sun, 19 Nov 2000, Cees de Groot wrote:
>
> wade@fizzylab.com said:
> > any insight as to how one might code something like that?
>
> Document traversal is a simple recursive Python function - with one call to
> objectValues on a folder you can extract all documents (and iterate over them,
> check their creation date, remove them if necessary); with a second call to
> objectValues you get all subfolders and recurse into them.
>
> objectValues matches on meta type, which is 'Folder' for a folder, and 'DTML
> Method' for a DTML method. So you'd get something like:
>
> def expire(folder):
> for i in self.objectItems('DTML Method'):
> id = i[0]; value = i[1]
> if value.bobobase_modification_time() < """now minus two weeks""":
> # remove i. Maybe tricky because you're iterating
> # and removing from a collection. check.
> folder.manage_delObjects(id)
> for i in folder.objectValues('Folder'):
> expire(i)
>
> Add this as a Python method (or similar) to the top-level folder where you
> want to expire, and kicking it off is as simple as a HTTP GET from a cron job
> (I think there's a job scheduler for Zope as well, should make it even easier).
>
> Disclaimer: untested, untested, and I never tried this out.