Re: multiple callbacks

"David Goodger" <[email protected]> Fri, 27 Jun 2008 13:04:31 -0400
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
On Fri, Jun 27, 2008 at 12:31,  <[email protected]> wrote:
> [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?

I have never felt the need for it, and have never heard of anyone
needing it before now.

In any case, I don't know if this is a useful forum for discussions of
Optik's development any more. It seems like Optik's author, Greg Ward,
has lost interest in it. It is only being maintained in Python's
standard library as optparse.py.

-- 
David Goodger <http://python.net/~goodger>

-------------------------------------------------------------------------
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