Re: Extending Zope2 bin/instance run

Wichert Akkerman <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
On 9/3/10 18:21 , Tres Seaver wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Wichert Akkerman wrote:
>> I have noticed that now that we are almost exclusively using eggs to
>> distribute our software using "bin/instance run" has become difficult:
>> often the script you want to run is located inside an egg which makes to
>> path to it hard to predict. This is not the most user friendly command:
>>
>>     bin/instance run eggs/my.package-*/my/package/script.py
>>
>> If a user is using a shared egg directory from zc.buildout or something
>> else the egg can be anywhere on the filesystem, making it next to
>> impossible to explain to users.
>>
>> I am considering to modify bin/instance run to check if its first
>> argument is a filesystem path, and if not consider the argument to be a
>> dotted name of a callable which should be invoke. That way backwards
>> compatibility remains, but you can now also do this:
>>
>>     bin/instance run my.package.script.main
>
> What about using something like the EntryPoint syntax:
>
>   $ bin/instance run my.package.script:main
>
> We could even add a new entry point class for it, and allow:
>
>   $ bin/instance run egg:my.package#some_name

I've opted for a third alternative: use an entry point to define the 
extra commands. If you do this in setup.py:

    entry_points="""
       [zopectl.command]
       mycommand = mypackage.commands:func
       """

you can do:

     $ bin/instance mycommand [<args>]

The advantage of this approach is that it makes for more user friendly 
commands that do not needlessly expose implementation details to the
commandline.

Wichert.
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.