Packing data.fs programmatically
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
Jonathan Cleaver wrote:
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!
zeopack.py in the utilities\ZODBTools folder of your Zope distro is what you're after, no need for home-grown hackishness...
-------------------------- 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".
My guess is that your environment is set up differently when it fails, PYTHON_PATH and the like... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Tue, Jan 31, 2006 at 11:38:34AM +0000, Jonathan Cleaver wrote:
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!
I do it though the webinterface with a wget from the crontab: @daily cd /some_path/zeo_server/var && \ cp Data.fs Data.fs.pre_pack_backup && \ /usr/local/bin/wget \ 'http://myzopeserver/Control_Panel/Database/manage_pack?days:float=0'\ --http-user=special_user \ --http-passwd='some_password' \ --spider &&\ cp Data.fs Data.fs.post_pack_backup -- __________________________________________________ "Nothing is as subjective as reality" Reinoud van Leeuwen reinoud.v@n.leeuwen.net http://www.xs4all.nl/~reinoud __________________________________________________
Ah-ha, that's another approach I had not thought of! Many thanks! Cheers Jonathan Reinoud van Leeuwen wrote:
On Tue, Jan 31, 2006 at 11:38:34AM +0000, Jonathan Cleaver wrote:
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!
I do it though the webinterface with a wget from the crontab:
@daily cd /some_path/zeo_server/var && \ cp Data.fs Data.fs.pre_pack_backup && \ /usr/local/bin/wget \ 'http://myzopeserver/Control_Panel/Database/manage_pack?days:float=0'\ --http-user=special_user \ --http-passwd='some_password' \ --spider &&\ cp Data.fs Data.fs.post_pack_backup
Reinoud van Leeuwen wrote:
On Tue, Jan 31, 2006 at 11:38:34AM +0000, Jonathan Cleaver wrote:
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!
I do it though the webinterface with a wget from the crontab:
@daily cd /some_path/zeo_server/var && \ cp Data.fs Data.fs.pre_pack_backup && \ /usr/local/bin/wget \ 'http://myzopeserver/Control_Panel/Database/manage_pack?days:float=0'\ --http-user=special_user \ --http-passwd='some_password' \ --spider &&\ cp Data.fs Data.fs.post_pack_backup
Oh, ouch ouch bad fragile pain failure suffering... URL whacking is evil and must be punished... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote:
Reinoud van Leeuwen wrote:
I do it though the webinterface with a wget from the crontab:
@daily cd /some_path/zeo_server/var && \ cp Data.fs Data.fs.pre_pack_backup && \ /usr/local/bin/wget \
'http://myzopeserver/Control_Panel/Database/manage_pack?days:float=0'\ --http-user=special_user \ --http-passwd='some_password' \ --spider &&\ cp Data.fs Data.fs.post_pack_backup
Oh, ouch ouch bad fragile pain failure suffering...
URL whacking is evil and must be punished...
What is the better way then? ZEO and ordinary Python scripts? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science
ZEO & Stepper.... Or if you don't like Stepper, then zopectl run... Chris Max M wrote:
Chris Withers wrote:
Reinoud van Leeuwen wrote:
I do it though the webinterface with a wget from the crontab:
@daily cd /some_path/zeo_server/var && \ cp Data.fs Data.fs.pre_pack_backup && \ /usr/local/bin/wget \
'http://myzopeserver/Control_Panel/Database/manage_pack?days:float=0'\ --http-user=special_user \ --http-passwd='some_password' \ --spider &&\ cp Data.fs Data.fs.post_pack_backup
Oh, ouch ouch bad fragile pain failure suffering...
URL whacking is evil and must be punished...
What is the better way then? ZEO and ordinary Python scripts?
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Tue, Jan 31, 2006 at 01:36:36PM +0000, Chris Withers wrote:
ZEO & Stepper....
Or if you don't like Stepper, then zopectl run...
Chris
Sounds interesting. Do you have a working example that you can post here? -- __________________________________________________ "Nothing is as subjective as reality" Reinoud van Leeuwen reinoud.v@n.leeuwen.net http://www.xs4all.nl/~reinoud __________________________________________________
The product comes with a whole raft of examples for doing things: http://www.simplistix.co.uk/software/zope/stepper base.py and config.py contain the examples, lemme know if you have any problems... Chris Reinoud van Leeuwen wrote:
On Tue, Jan 31, 2006 at 01:36:36PM +0000, Chris Withers wrote:
ZEO & Stepper....
Or if you don't like Stepper, then zopectl run...
Chris
Sounds interesting. Do you have a working example that you can post here?
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris, On Tue, Jan 31, 2006 at 01:36:36PM +0000, Chris Withers wrote: | ZEO & Stepper.... Is ZEO required to use Stepper? | Or if you don't like Stepper, then zopectl run... Does 'zopectl run' require exclusive access to the database? (IOW must the zope server be stopped before zopectl run can be used?) I just came across this thread and have a situation where this would be useful, however ZEO is not used for that deployment. -D -- The fear of the Lord leads to life: Then one rests content, untouched by trouble. Proverbs 19:23 www: http://dman13.dyndns.org/~dman/ jabber: dman@dman13.dyndns.org
On Thu, Feb 23, 2006 at 11:27:59AM -0500, Derrick Hudson wrote:
Does 'zopectl run' require exclusive access to the database? (IOW must the zope server be stopped before zopectl run can be used?)
Yes, IFF you are not running zeo. That's another useful reason to use zeo :-)
I just came across this thread and have a situation where this would be useful, however ZEO is not used for that deployment.
Ah, that's a shame. -- Paul Winkler http://www.slinkp.com
Derrick Hudson wrote:
Chris,
On Tue, Jan 31, 2006 at 01:36:36PM +0000, Chris Withers wrote: | ZEO & Stepper....
Is ZEO required to use Stepper?
Yes, otherwise you'd have to shut down your Zope instance to run Stepper ;-)
Does 'zopectl run' require exclusive access to the database? (IOW must the zope server be stopped before zopectl run can be used?)
Not if you're using ZEO.
I just came across this thread and have a situation where this would be useful, however ZEO is not used for that deployment.
Then introduce it, it's simple to set up and adds a world of functionality! Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Fri, Feb 24, 2006 at 09:18:35PM +0000, Chris Withers wrote: | Derrick Hudson wrote: | >Chris, | > | >On Tue, Jan 31, 2006 at 01:36:36PM +0000, Chris Withers wrote: | >| ZEO & Stepper.... | > | >Is ZEO required to use Stepper? | | Yes, otherwise you'd have to shut down your Zope instance to run Stepper ;-) | | >Does 'zopectl run' require exclusive access to the database? (IOW | >must the zope server be stopped before zopectl run can be used?) | | Not if you're using ZEO. Thanks Paul and Chris. | >I just came across this thread and have a situation where this would | >be useful, however ZEO is not used for that deployment. | | Then introduce it, it's simple to set up and adds a world of | functionality! I could. I'd have to learn how to work with it :-). The deployments I've worked with are all single uniprocessor machines, thus ZEO wouldn't yield a performance improvement. I should learn ZEO one of these days. -D -- If you hold to [Jesus'] teaching, you are really [Jesus'] disciples. Then you will know the truth, and the truth will set you free. John 8:31-32 www: http://dman13.dyndns.org/~dman/ jabber: dman@dman13.dyndns.org
On 25 Feb 2006, at 04:27, Derrick Hudson wrote:
| Then introduce it, it's simple to set up and adds a world of | functionality!
I could. I'd have to learn how to work with it :-). The deployments I've worked with are all single uniprocessor machines, thus ZEO wouldn't yield a performance improvement. I should learn ZEO one of these days.
Thinking of ZEO just as a "performance improvement" is doing it a great disservice. Think of it simply in terms of decoupling the appserver from the database server and the flexibility that gives you by being able to access the database server separately. jens
On Tue January 31 2006 07:47, Chris Withers wrote:
I do it though the webinterface with a wget from the crontab:
Oh, ouch ouch bad fragile pain failure suffering...
URL whacking is evil and must be punished...
How is this different than clicking on the Pack button in the ZMI? What's the solution without ZEO and without having to stop Zope? -- Ron
Ron Bickers wrote:
On Tue January 31 2006 07:47, Chris Withers wrote:
I do it though the webinterface with a wget from the crontab:
Oh, ouch ouch bad fragile pain failure suffering...
URL whacking is evil and must be punished...
How is this different than clicking on the Pack button in the ZMI?
That's also evil, because yes, it is just URL whacking with a browser...
What's the solution without ZEO and without having to stop Zope?
You use ZEO. Get over it, it should be how a standard Zope instance is set up, IMNSHO... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Fri February 24 2006 16:19, Chris Withers wrote:
URL whacking is evil and must be punished...
How is this different than clicking on the Pack button in the ZMI?
That's also evil, because yes, it is just URL whacking with a browser...
Ok. So there is no difference.
What's the solution without ZEO and without having to stop Zope?
You use ZEO. Get over it, it should be how a standard Zope instance is set up, IMNSHO...
So, in other words, there isn't one. I take it you're a big fan of ZEO. ;-) I guess I'll check it out. I've been using Zope for 7-ish years and just never bothered. -- Ron
Ron Bickers wrote:
What's the solution without ZEO and without having to stop Zope? You use ZEO. Get over it, it should be how a standard Zope instance is set up, IMNSHO...
So, in other words, there isn't one. I take it you're a big fan of ZEO. ;-) I guess I'll check it out. I've been using Zope for 7-ish years and just never bothered.
Well exactly. ZEO is not only for scaling Zope to multiple app serving clients, it's the way that ZODB allows multiple processes to access a single database. Think of it in the same way as you'd thing of something like MySQLDB, psycopg or DCOracle2... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Jonathan Cleaver wrote at 2006-1-31 11:38 +0000:
... 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".
*ALWAYS* look at the traceback! It tells you where precisely the error happens... -- Dieter
participants (9)
-
Chris Withers -
Derrick Hudson -
Dieter Maurer -
Jens Vagelpohl -
Jonathan Cleaver -
Max M -
Paul Winkler -
Reinoud van Leeuwen -
Ron Bickers