launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #04673
how to use feature flags
Just noticed while discussing stuff with Maris that feature flags are
being used in a very odd way.
This is the right way to use a flag in a template:
<div tal:condition="features/FLAG_NAME">...</div>
For instance
<div tal:condition="features/soyuz.derived-series-ui.enabled">...</div>
This will execute when the flag is defined to a non-None, non-empty
string value.
To use a flag in python code:
if features.getFeatureFlag('soyuz.derived-series-ui.enabled'):
...
Will do precisely the same thing.
Finally, if you need to get a value back, you can interpret the flag. E.g.
value = features.getFeatureFlag('soyuz.derived-series-ui.enabled')
if value:
print value
-Rob
Follow ups