[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Maintaining
Zope
webmaster at zope.org
webmaster at zope.org
Wed Mar 10 07:53:02 EST 2004
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/MaintainingZope.stx#2-40
---------------
If you want to automatically pack the ZODB you could tickle the
appropriate URL with a small python script (the traditional
filesystem based kind, not Zopes "Script (Python)")::
#!/usr/bin/python
import sys, urllib
host = sys.argv[1]
days = sys.argv[2]
url = "%s/Control_Panel/Database/manage_pack?days:float=%s" % \
(host, days)
try:
f = urllib.urlopen(url).read()
except IOError:
print "Cannot open URL %s, aborting" % url
print "Successfully packed ZODB on host %s" % host
% Anonymous User - Dec. 4, 2003 6:55 pm:
Is it really possible to pack anonymously through-the-web?
Shouldn't everything in the control panel require authentication?
% Anonymous User - Dec. 6, 2003 12:58 pm:
I just checked with zope 2.6.2... authentication is required to tickle that URL.
% Anonymous User - Mar. 10, 2004 6:35 am:
http://user:password@host:port/...
% Anonymous User - Mar. 10, 2004 7:53 am:
Automatically pack the ZODB with user/password
This works! Please change the script above, because
the original script makes no sense.
#!/usr/bin/python
import sys, urllib
host = sys.argv[1]
days = sys.argv[2]
user = sys.argv[3]
pwd = sys.argv[4]
class MyUrlOpener(urllib.FancyURLopener):
def prompt_user_passwd(self, host, realm):
return (user,pwd)
def __init__(self, *args):
self.version = "Zope Packer"
urllib.FancyURLopener.__init__(self, *args)
def main():
urllib._urlopener = MyUrlOpener()
url = "%s/Control_Panel/Database/manage_pack?days:float=%s" % \
(host, days)
try:
f = urllib.urlopen(url).read()
except IOError:
print "Cannot open URL %s, aborting" % url
print "Successfully packed ZODB on host %s" % host
if __name__ == '__main__':
main()
More information about the ZDP
mailing list