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.

16 lines
341 B

  1. import uuid
  2. from functools import wraps
  3. from django.http import HttpResponseBadRequest
  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