Re: multiple callbacks

[email protected] Fri, 27 Jun 2008 11:31:40 -0500
Newsgroups gmane.comp.python.optik.user
Message-ID <OF53256A2F.84A22F2E-ON86257475.0059CA81-86257475.005AC9FF@uscmail.uscourts.gov>
[email protected] wrote on 06/27/2008 09:26:47 AM:

> On Thu, Jun 26, 2008 at 20:17,  <[email protected]> wrote:
> > So after reading through the docs and looking in the code a bit (gotta
love
> > open source), it occurred to me that it might be a "nice" feature to be
> > able to provide multiple callbacks per option.
>
> This is easy to do from your own code. Just define a closure function:
>
> def multiple_callbacks(*callbacks):
>     """Returns a callback that calls multiple callbacks."""
>     def call_multiple_callbacks(option, opt, value, parser):
>         for callback in callbacks:
>             callback(option, opt, value, parser)
>     return call_multiple_callbacks
>
> OPTIONS_LIST = [
>  make_option('-c', '--chroot', default=None,
>      action='callback',
>      callback=multiple_callbacks(check_path_exists, check_path_isdir),
>      help="specifies the root of the chroot environment to work with"),
> ...
>

Nice.  I like that.. and I will probably use that.  Thank you.  So, do this
not seem like it would be a valuable function to have in optik?

-greg


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php