Manager API reference¶
This document describes the Switch Manager API. This is generally referred to
as the global gargoyle object, which lives in gargoyle.gargoyle.
-
class
gargoyle.manager.SwitchManager(*args, **kwargs)¶ -
get_all_conditions()¶ Returns a generator which yields groups of lists of conditions.
>>> for set_id, label, field in gargoyle.get_all_conditions(): >>> print("%(label)s: %(field)s" % (label, field.label))
-
get_condition_set_by_id(switch_id)¶ Given the identifier of a condition set (described in ConditionSet.get_id()), returns the registered instance.
-
get_condition_sets()¶ Returns a generator yielding all currently registered ConditionSet instances.
-
is_active(key, *instances, **kwargs)¶ Returns
Trueif any ofinstancesmatch an active switch. Otherwise returnsFalse.>>> gargoyle.is_active('my_feature', request)
-
register(condition_set)¶ Registers a condition set with the manager.
>>> condition_set = MyConditionSet() >>> gargoyle.register(condition_set)
-
unregister(condition_set)¶ Unregisters a condition set with the manager.
>>> gargoyle.unregister(condition_set)
-
Switches are handled through the ModelDict interface, which is registered under the Switch model.