← Back to team overview

launchpad-dev team mailing list archive

Re: how to use feature flags

 

On Tue, Sep 21, 2010 at 8:41 AM, Martin Pool <mbp@xxxxxxxxxxxxx> wrote:
> On 18 September 2010 11:01, Robert Collins <robert.collins@xxxxxxxxxxxxx> wrote:
>> Just noticed while discussing stuff with Maris that feature flags are
>> being used in a very odd way.
>
> Just for easier future reference than grepping mail, this is described
> in <https://code.launchpad.net/~mbp/launchpad/flags-webapp/+merge/32967>
> lands, this will be in the lib.lp.services.features docstring.  At the
> moment it's in a docfile under that directory.   If anything else is
> unclear please do ask.

The only thing that was unclear for me was how to switch the feature
on for testing when using getFeatureFlag(). I ended up with the
following helper... is there a better way to do this?

{{{
    def setDerivedSeriesUIFeatureFlag(self):
        # Helper to set the feature flag enabling the derived series ui.
        ignore = getFeatureStore().add(FeatureFlag(
            scope=u'default', flag=u'soyuz.derived-series-ui.enabled',
            value=u'on', priority=1))

        # XXX Michael Nelson 2010-09-21 bug=631884
        # Currently LaunchpadTestRequest doesn't set per-thread
        # features.
        def in_scope(value):
            return True
        per_thread.features = FeatureController(in_scope)

        def reset_per_thread_features():
            per_thread.features = None
        self.addCleanup(reset_per_thread_features)
}}}
>
> --
> Martin
>
> _______________________________________________
> Mailing list: https://launchpad.net/~launchpad-dev
> Post to     : launchpad-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~launchpad-dev
> More help   : https://help.launchpad.net/ListHelp
>



Follow ups

References