Providers
Context
Bases: UserDict
Context contains contextual data for use by experiments in determining matching variants.
identity(keypath, seed)
Uses context data to calculate an identity for the given keypath and seed.
| Parameters: |
|
|---|
keypath has a special value, "random", that will return a random value
for use as the identity. Seed has no effect if "random" is used as the
keypath.
Identity values are cached so, the same keypath/seed pair will not be re-calculated if identity() is called again.
| Raises: |
|
|---|
ContextProvider
Bases: ABC
Base class for context providers.
Context providers populate contexts.
context(**kwargs)
abstractmethod
Constructs a context.
DjangoRequestContextProvider
Bases: ContextProvider
A context provider for Django environments.
Pre-populates the context with the Django user (user) and tracking key for
identifying anonymous users (anonymous).
context(**kwargs)
Constructs a DjangoRequestContextProvider.
| Parameters: |
|
|---|
Source
Bases: ABC
Protocol for experiment sources.
Classes implementing this protocol must provide a load method that returns
an iterable of Experiment instances. This allows flexible sourcing of
experiments from different backends (e.g., settings, database, API).
load()
abstractmethod
Loads all experiments that the project should be aware of.
For projects that use cravensworth_middleware, load() will be called
for every request.