You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
340 B

  1. from functools import wraps
  2. from django.http import HttpResponseBadRequest
  3. import uuid
  4. def uuid_or_400(f):
  5. @wraps(f)
  6. def wrapper(request, *args, **kwds):
  7. try:
  8. uuid.UUID(args[0])
  9. except ValueError:
  10. return HttpResponseBadRequest()
  11. return f(request, *args, **kwds)
  12. return wrapper