Skip to content
This repository

Allow options to be mutable #666

emehrkay opened this Issue January 12, 2013 · 3 comments

2 participants

Mark Henderson Ben Darnell
Mark Henderson

With a simple flag we could be able to change an existing option later in code


    def define(self, name, default=None, type=None, help=None, metavar=None,
               multiple=False, group=None, mutable=False):
        if name in self and not mutable:


Ben Darnell

Why would you want to do that?

Mark Henderson

Sometimes I like to redefine some of the site options. For example: if I define list display order as descending, and reference that option when creating the list, id like to give a user the opportunity to order the list in a different way. Since I originally used an option to define order and used it throughout the code, I have to redefine the option for it to take.

I've been using:

from tornado.options import options, _Option
options['name'] = _Option(name, default=new_value, ...)

Just figured it could be easier.

Ben Darnell

For your example about list display order, it sounds like the right answer is for the display function to take an order argument instead of relying on the global option. Redefining anything but the default value in this way seems dangerous. Since tornado 2.3 it's been possible to say " = new_value", which should be good enough. Is there any reason I'm missing to redefine the option with a new default instead of just setting it to a new value?

Ben Darnell bdarnell closed this April 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.