-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hello All,
Trying to create a custom condition. Here is the code (which I have put in conditions.py in my django project, and imported.
@conditions.register('is_tester')
def is_tester_condition(request=None, **kwargs):
"""
Django-Flags condition that requires an authcode passed in request, and
determines if that authcode belongs to a tester, or is in a tester group.
Returns True if yes, False otherwise.
"""
logger.debug(f"is_tester_condition: kwargs: {kwargs}")
authcode = request.GET.get("authCode", "").lower()
if request is None:
raise conditions.RequiredForCondition(
"request is required for condition 'is_tester'"
)
if not authcode:
raise conditions.RequiredForCondition(
"authCode is required for condition 'is_tester'"
)
return TrueI have another section of code that calls
for flag in get_flags():
if flag_enabled (flag, request=request):
do whateverwhen this code runs, I get:
TypeError: is_tester_condition() got multiple values for argument 'request'
If I remove the request=None param from the condition definition, I get that the function takes 0 arguments, but is given 1.
Do you have an examples of custom conditions anywhere? Any ideas why it thinks request is being sent twice?
Metadata
Metadata
Assignees
Labels
No labels