[Zope] Packing data.fs programmatically

Jonathan Cleaver jcleaver.hq at da.mod.uk
Tue Jan 31 06:38:34 EST 2006


I am using the following module to pack my data.fs programmatically 
before a backup is made. This was largely taken out of the Zopelabs 
cookbook - thanks!

------------------------

def packZODB():

   try:
     import os, sys
     os.chdir("/path/to/Zope/python")
     sys.path+=['/path/to/Zope/python/was/required/to/load/Zope/module']
     import Zope
     Zope.configure("/path/to/zope.conf")

     app = Zope.app()

     app.Control_Panel.Database.manage_pack(days=0)
     get_transaction().commit()
     app._p_jar.close()

     return 1

   except Exception, inst:
     for arg in inst.args:
       print "Oh dear! %s" % arg

--------------------------
Now for the wierd bit. I successfully ran the code that went into this 
module line-by-line in the Python interpreter. The data.fs was 
beautifully packed. However, when I run this script from the command 
line (through another script that acts as a hook) the line "app = 
Zope.app()" fails with the error "No such file or directory".

Now I am confused, coz the code lines that you would expect to fail if 
either of the required paths were not correct ran quite happily.

I am running Python 2.3.5 and Zope 2.7.

Does anyone have any thoughts?

Cheers

Jonathan Cleaver



More information about the Zope mailing list