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)

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))

Given the identifier of a condition set (described in ConditionSet.get_id()), returns the registered instance.


Returns a generator yielding all currently registered ConditionSet instances.

is_active(key, *instances, **kwargs)

Returns True if any of instances match an active switch. Otherwise returns False.

>>> gargoyle.is_active('my_feature', request)

Registers a condition set with the manager.

>>> condition_set = MyConditionSet()
>>> gargoyle.register(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.