[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup - zopectl.py:1.3.2.3 zopeschema.xml:1.7.2.3

Chris McDonough chrism@zope.com
Thu, 24 Jul 2003 16:29:28 -0400


Update of /cvs-repository/Zope/lib/python/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv24179

Modified Files:
      Tag: Zope-2_7-branch
	zopectl.py zopeschema.xml 
Log Message:
New zopectl feature: adduser.  Instead of using the inituser mechanism,
"zopectl adduser <name> <password>" will add a user with the 'Manager' role
to your site.  This is useful both interactively and for packagers.

Bugfix: if zopectl is run as the root user, the debug, run, and adduser
commands will cause the Python process which performs those actions
to switch users to the effective user.  This prevents ZODB index files,
log files, etc. from being written as root, potentially preventing
later startup by the effective user.

Bugfix: allow the zopectl process to ascertain the program that zdrun should
run from the Zope config file.  This is necessary if the file is moved
out of a "single-directory-as-instance" instance home.



=== Zope/lib/python/Zope/Startup/zopectl.py 1.3.2.2 => 1.3.2.3 ===
--- Zope/lib/python/Zope/Startup/zopectl.py:1.3.2.2	Mon Jul 21 12:37:47 2003
+++ Zope/lib/python/Zope/Startup/zopectl.py	Thu Jul 24 16:29:22 2003
@@ -45,6 +45,9 @@
 from zLOG.datatypes import FileHandlerFactory
 
 
+def string_list(arg):
+    return arg.split()
+
 class ZopeCtlOptions(ZDOptions):
     """Zope controller options.
 
@@ -65,6 +68,8 @@
 
     def __init__(self):
         ZDOptions.__init__(self)
+        self.add("program", "runner.program", "p:", "program=",
+                 handler=string_list)
         self.add("backofflimit", "runner.backoff_limit",
                  "b:", "backoff-limit=", int, default=10)
         self.add("daemon", "runner.daemon", "d", "daemon", flag=1, default=1)
@@ -82,7 +87,10 @@
         config = self.configroot
         self.directory = config.instancehome
         self.clienthome = config.clienthome
-        self.program = [os.path.join(self.directory, "bin", "runzope")]
+        if config.runner and config.runner.program:
+            self.program = config.runner.program
+        else:
+            self.program = [os.path.join(self.directory, "bin", "runzope")]
         self.sockname = os.path.join(self.clienthome, "zopectlsock")
         self.user = None
         self.python = sys.executable
@@ -133,12 +141,14 @@
                     'opts.configfile=\'%s\'; '
                     'opts.realize(); '
                     'h.handleConfig(opts.configroot,opts.confighandlers);'
-                    'config.setConfiguration(opts.configroot); ' %
+                    'config.setConfiguration(opts.configroot); '
+                    'from Zope.Startup import do_posix_stuff; '
+                    'do_posix_stuff(opts.configroot); '%
                     (python, self.options.configfile)
                     )
         return cmdline + more + '\"'
 
-    def do_debug( self, arg ):
+    def do_debug(self, arg):
         cmdline = self.get_startup_cmd(self.options.python + ' -i',
                                        'import Zope; app=Zope.app()')
         print ('Starting debugger (the name "app" is bound to the top-level '
@@ -149,7 +159,8 @@
         print "debug -- run the Zope debugger to inspect your database"
         print "         manually using a Python interactive shell"
 
-    def do_run( self, arg ):
+    def do_run(self, arg):
+        self.setuid()
         cmdline = self.get_startup_cmd(self.options.python,
             'import Zope; app=Zope.app(); execfile(\'%s\')' % arg)
         os.system(cmdline)
@@ -158,6 +169,23 @@
         print "run <script> -- run a Python script with the Zope environment"
         print "                set up.  The script can use the name 'app' to"
         print "                access the top-level Zope object"
+
+    def do_adduser(self, arg):
+        try:
+            name, password = arg.split()
+        except:
+            print "usage: adduser <name> <password>"
+            return
+        cmdline = self.get_startup_cmd(
+            self.options.python ,
+            'import Zope; app=Zope.app();'
+            'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []);'
+            'get_transaction().commit()'
+            ) % (name, password)
+        os.system(cmdline)
+
+    def help_adduser(self):
+        print "adduser <name> <password> -- add a Zope management user"
 
 
 def main(args=None):


=== Zope/lib/python/Zope/Startup/zopeschema.xml 1.7.2.2 => 1.7.2.3 ===
--- Zope/lib/python/Zope/Startup/zopeschema.xml:1.7.2.2	Mon Jul 21 12:37:47 2003
+++ Zope/lib/python/Zope/Startup/zopeschema.xml	Thu Jul 24 16:29:22 2003
@@ -46,8 +46,14 @@
       here too.
     </description>
 
+    <multikey name="program" required="no">
+      <description>
+       The program(s) that will be run by the runner
+      </description>
+    </multikey>
+
     <key name="daemon" datatype="boolean"
-	 required="no" default="false">
+	 required="no" default="true">
       <description>
         Command-line option: -d or --daemon.
 
@@ -163,6 +169,15 @@
        Use a Python dotted-path name to specify the class factory function.
       </description>
     </key>
+
+    <key name="container-class" datatype=".importable_name">
+      <description>
+       Change the contiainer class a (mounted) database uses on a
+       per-database basis to support a different container than a plain
+       Folder. Use a Python dotted-path name to specify the container class.
+      </description>
+    </key>
+
   </sectiontype>
 
   <!-- end of type definitions -->