[Zope-Coders] DISCUSS: Let's make zctl official

Paul Everitt paul@zope.com
Wed, 12 Dec 2001 12:50:29 -0500


How does ObjectCLI compare with ZShell:

   http://www.zope.org/Members/jerome_alet/zshell

...which, according to the changelog:

  http://cortex.unice.fr/~jerome/zshell/NEWS

...has a CLI based on xml-rpc:

"""
You can now use ZShell from ZShellCLI, a true CLI
developped by Andy McKay, which is now part of this
package (in the ZShellCLI directory).
"""

--Paul

Shane Hathaway wrote:

> Paul Everitt wrote:
> 
>>
>> Howdy.  It seems that a lot of insiders love to use zctl to administer 
>> their Zope processes.  Unfortunately:
>>
>>   o There are a number of versions lying around.
>>
>>   o Documentation is scattered.
>>
>>   o Few people know about it.
>>
>> There are proposals in the fishbowl about it.  I think this would be 
>> nice, bite-sized chunk for a committer to pick up and get into Zope.
>>
>> Casey picked up "Death to index_html" (or the aspect related to 
>> configuring object creation, I believe).  Who wants to be second to 
>> tackle a much-needed improvement in Zope?
> 
> 
> Before we integrate zctl, I'd like to suggest a simple rearchitecting of 
> zctl for extensibility and simplicity.  In my "pma" project I came up 
> with a way to create a command-line interface for Python objects, 
> similar to the way ZPublisher provides a Web interface for Python 
> objects.  Command-line arguments are transparently translated into 
> arguments to a function call.
> 
> An example:
> 
> 
> class ZopeCtl:
>   """Zope control program.
>   """
> 
>   def start_zeo(self, host='', port=12345):
>      """Starts the ZEO server.
> 
>      --host (optional): the hostname to listen on.
>      --port (optional): the port to serve.
>      """
>      # Do stuff here
> 
> def main():
>   from objectcli import ObjectCLI
>   cli = ObjectCLI(ZopeCtl())
>   cli()
> 
> if __name__ == '__main__':
>   main()
> 
> 
> ObjectCLI provides a standardish command-line interface.  It expects a 
> command which corresponds to a method name as the first argument.  If it 
> does not get a command or it gets "--help", it prints usage information 
> from the ZopeCtl docstring and the docstrings of the methods.  If it 
> gets a command followed by "--help", it prints detailed information 
> provided by the docstring of a method.
> 
> ObjectCLI uses getopt() to do its work.  The really neat thing is you 
> can just subclass ZopeCtl to add or modify commands.  That way 
> ZServerSSL wouldn't need to patch zctl, for example.
> 
> You can find objectcli.py at the URL below.  I'm thinking of suggesting 
> it be added to the Python standard library, but only after it gets some 
> mileage.
> 
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/zodbex/zodbex/pma/objectcli.py?rev=1.2&content-type=text/vnd.viewcvs-markup 
> 
> 
> Shane
>