[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Maintaining Zope

webmaster at zope.org webmaster at zope.org
Wed May 5 13:44:03 EDT 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()

      % Anonymous User - Mar. 16, 2004 11:35 am:
       In the example above, you used 
       > url = "%s/Control_panel/Database/manage_pack?days;float=%s" % (host, days)
       Does this function pack all the DBs? For example I want to use some databases for virtual hosting and I need
       to pack all of them periodically. What about the time of this operation? I meet some strange feature: little
       db Test.fs (about 5KB size) was packed during 1 second - browser showed me new size (about 3KB), and file
       Test.fs.old appeared. Attempt to pack database again raises an error:
       Error Type: FileStorageError
       Error Value: The database has already been packed to a later time or no changes have been made since the last
       pack
       OK.
       The same operation with another db Main.fs (about 3MB) leaded to the following:
       -browser showed page, where size was the same as before starting pack, and no file appeared in var directory.
       -attempt to repack the db leads to error:
       Error Type: FileStorageError
       Error Value: Already packing
       About 20 minutes passed but nothing changed.

       So how can I know the moment of packing finish?
       At what time should I backup the db file?

      % Anonymous User - May 5, 2004 1:44 pm:
       The form with .../Database packs the Data.fs 
       I tested with  .../Database/mydb/manage_pack?days:float=x and is compresses mydb correctl
       So: "/usr/bin/curl -s http://user:pwd@localhost:8080/Control_Panel/Database/mydb/manage_pack?days:float=0" is
       fine



More information about the ZDP mailing list