[Checkins] SVN: zc.monitor/trunk/src/zc/monitor/ Added a function to register the basic commands and removed the
Jim Fulton
jim at zope.com
Mon Dec 12 11:54:31 UTC 2011
Log message for revision 123725:
Added a function to register the basic commands and removed the
examples of using zope.component.
Changed:
U zc.monitor/trunk/src/zc/monitor/README.txt
U zc.monitor/trunk/src/zc/monitor/__init__.py
-=-
Modified: zc.monitor/trunk/src/zc/monitor/README.txt
===================================================================
--- zc.monitor/trunk/src/zc/monitor/README.txt 2011-12-12 11:53:14 UTC (rev 123724)
+++ zc.monitor/trunk/src/zc/monitor/README.txt 2011-12-12 11:54:31 UTC (rev 123725)
@@ -27,13 +27,16 @@
and register it:
- >>> import zope.component, zc.monitor.interfaces
- >>> zope.component.provideUtility(
- ... hello, zc.monitor.interfaces.IMonitorPlugin, 'hello')
+ >>> zc.monitor.register(hello)
+When we register a command, we can provide a name. To see this, we'll
+register ``hello`` again:
+
+ >>> zc.monitor.register(hello, 'hi')
+
Now we can give the hello command to the server:
- >>> connection.test_input('hello\n')
+ >>> connection.test_input('hi\n')
Hi world, nice to meet ya!
-> CLOSE
@@ -49,19 +52,8 @@
them so we can see what they do. We'll use the simplfied registration
interface:
- >>> zc.monitor.register(zc.monitor.help)
- >>> zc.monitor.register(zc.monitor.interactive)
- >>> zc.monitor.register(zc.monitor.quit)
+ >>> zc.monitor.register_basics()
-The simplified interface takes a command object (usually a function)
-and an optional name. Bu default, the name is taken from the
-``__name__`` attribute of the command. You can also specify a name:
-
- >>> zc.monitor.register(zc.monitor.quit, 'exit')
-
-The simplified interface simply registers a utility, as we did above
-for the hello command.
-
The first is the help command. Giving help without input, gives a
list of available commands:
@@ -69,9 +61,9 @@
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('help\n')
Supported commands:
- exit -- Quit the monitor
hello -- Say hello
help -- Get help about server commands
+ hi -- Say hello
interactive -- Turn on monitor's interactive mode
quit -- Quit the monitor
-> CLOSE
@@ -192,8 +184,7 @@
If we register this command...
- >>> zope.component.provideUtility(calc,
- ... zc.monitor.interfaces.IMonitorPlugin, 'calc')
+ >>> zc.monitor.register(calc)
...we can invoke it and we get a prompt.
Modified: zc.monitor/trunk/src/zc/monitor/__init__.py
===================================================================
--- zc.monitor/trunk/src/zc/monitor/__init__.py 2011-12-12 11:53:14 UTC (rev 123724)
+++ zc.monitor/trunk/src/zc/monitor/__init__.py 2011-12-12 11:54:31 UTC (rev 123725)
@@ -159,3 +159,8 @@
name = command.__name__
zope.component.provideUtility(
command, zc.monitor.interfaces.IMonitorPlugin, name)
+
+def register_basics():
+ register(help)
+ register(interactive)
+ register(quit)
More information about the checkins
mailing list