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

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


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

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

-=-
Modified: zdaemon/trunk/tests/testzdrun.py
===================================================================
--- zdaemon/trunk/tests/testzdrun.py	2004-10-21 13:58:22 UTC (rev 28231)
+++ zdaemon/trunk/tests/testzdrun.py	2004-10-21 18:43:36 UTC (rev 28232)
@@ -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: zdaemon/trunk/zdctl.py
===================================================================
--- zdaemon/trunk/zdctl.py	2004-10-21 13:58:22 UTC (rev 28231)
+++ zdaemon/trunk/zdctl.py	2004-10-21 18:43:36 UTC (rev 28232)
@@ -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 Zodb-checkins mailing list