[Zope] expiring dtml documents

Cees de Groot cg@cdegroot.com
Sun, 19 Nov 2000 13:09:49 +0100


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.


-- 
Cees de Groot               http://www.cdegroot.com     <cg@cdegroot.com>
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD  1986 F303 937F E098 9E8B