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

[email protected]
Newsgroups gmane.comp.web.zope.zdp
Message-ID <[email protected]>
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()

_______________________________________________
ZDP maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zdp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.