[Zope3-checkins] SVN: Zope3/trunk/src/zdaemon/ make it possible to override the controller command class, to allow using

Fred L. Drake, Jr. fdrake at gmail.com
Thu Oct 21 14:46:13 EDT 2004


Log message for revision 28233:
  make it possible to override the controller command class, to allow using
  a derived class that provides more commands, or changes implementations of
  some
  (merged from zdaemon trunk revision 28232)
  

Changed:
  U   Zope3/trunk/src/zdaemon/tests/testzdrun.py
  U   Zope3/trunk/src/zdaemon/zdctl.py

-=-
Modified: Zope3/trunk/src/zdaemon/tests/testzdrun.py
===================================================================
--- Zope3/trunk/src/zdaemon/tests/testzdrun.py	2004-10-21 18:43:36 UTC (rev 28232)
+++ Zope3/trunk/src/zdaemon/tests/testzdrun.py	2004-10-21 18:46:13 UTC (rev 28233)
@@ -90,14 +90,21 @@
         ##os.system("PYTHONPATH=%s %s %s -s %s %s &" %
         ##    (self.ppath, self.python, self.zdrun, self.zdsock, args))
 
-    def run(self, args):
+    def run(self, args, cmdclass=None):
         if type(args) is type(""):
             args = args.split()
         try:
-            zdctl.main(["-s", self.zdsock] + args)
+            zdctl.main(["-s", self.zdsock] + args, cmdclass=cmdclass)
         except SystemExit:
             pass
 
+    def testCmdclassOverride(self):
+        class MyCmd(zdctl.ZDCmd):
+            def do_sproing(self, rest):
+                print rest
+        self.run("-p echo sproing expected", cmdclass=MyCmd)
+        self.expect = "expected\n"
+
     def testSystem(self):
         self.rundaemon(["echo", "-n"])
         self.expect = ""

Modified: Zope3/trunk/src/zdaemon/zdctl.py
===================================================================
--- Zope3/trunk/src/zdaemon/zdctl.py	2004-10-21 18:43:36 UTC (rev 28232)
+++ Zope3/trunk/src/zdaemon/zdctl.py	2004-10-21 18:46:13 UTC (rev 28233)
@@ -564,11 +564,11 @@
     def fsize(self):
         return os.fstat(self.f.fileno())[stat.ST_SIZE]
 
-def main(args=None, options=None):
+def main(args=None, options=None, cmdclass=None):
     if options is None:
         options = ZDCtlOptions()
     options.realize(args)
-    c = ZDCmd(options)
+    c = cmdclass(options)
     if options.args:
         c.onecmd(" ".join(options.args))
     if options.interactive:



More information about the Zope3-Checkins mailing list