Add show_if and hide_if methods for routes and APIs, as well as proper comparison of feature values
This commit is contained in:
parent
0abbf042dd
commit
4f4112b18d
5 changed files with 71 additions and 5 deletions
|
@ -2,4 +2,24 @@ def import_features(config_dict):
|
|||
for feature, feature_val in config_dict.items():
|
||||
if feature.startswith('FEATURE_'):
|
||||
feature_name = feature[8:]
|
||||
globals()[feature_name] = feature_val
|
||||
globals()[feature_name] = FeatureNameValue(feature_name, feature_val)
|
||||
|
||||
|
||||
class FeatureNameValue(object):
|
||||
def __init__(self, name, value):
|
||||
self.value = value
|
||||
self.name = name
|
||||
|
||||
def __str__(self):
|
||||
return '%s => %s' % (self.name, self.value)
|
||||
|
||||
def __repr__(self):
|
||||
return self.value
|
||||
|
||||
def __cmp__(self, other):
|
||||
return self.value.__cmp__(other)
|
||||
|
||||
def __nonzero__(self):
|
||||
return self.value.__nonzero__()
|
||||
|
||||
|
||||
|
|
Reference in a new issue