i maintain a zope server that collects several hundred dtml documents per day. there is a need to have dtml documents removed 2 weeks after they are created. any suggestions on how to go about doing this?
wade naveja <wade@fizzylab.com> said:
i maintain a zope server that collects several hundred dtml documents per day. there is a need to have dtml documents removed 2 weeks after they are created. any suggestions on how to go about doing this?
I'd make a cron job that kicks off a bit of code inside Zope every night; let the code walk the tree and expire old documents. With ZEO you should be able to do this directly from a Python script. -- Cees de Groot http://www.cdegroot.com <cg@cdegroot.com> GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B
any insight as to how one might code something like that? On 18 Nov 2000, Cees de Groot wrote:
wade naveja <wade@fizzylab.com> said:
i maintain a zope server that collects several hundred dtml documents per day. there is a need to have dtml documents removed 2 weeks after they are created. any suggestions on how to go about doing this?
I'd make a cron job that kicks off a bit of code inside Zope every night; let the code walk the tree and expire old documents.
With ZEO you should be able to do this directly from a Python script.
-- Cees de Groot http://www.cdegroot.com <cg@cdegroot.com> GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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
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.
participants (2)
-
cg@cdegroot.com -
wade naveja