Skip to content

Instantly share code, notes, and snippets.

@Verurteilt
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Verurteilt/8994874 to your computer and use it in GitHub Desktop.
Save Verurteilt/8994874 to your computer and use it in GitHub Desktop.
#Encontrado en Google https://groups.google.com/forum/#!topic/django-users/RM7ZZ9naNQA
def obtener_request():
try:
user = None
outer_frames = inspect.getouterframes(inspect.currentframe())
for tpl in outer_frames:
arginfo = inspect.getargvalues(tpl[0])
if(type(arginfo[3]) is dict):
arg_dict = arginfo[3].copy()
for k in arg_dict:
if(type(arg_dict.get(k)) is WSGIRequest):
#user = arg_dict.get(k).user
#path = arg_dict.get(k).path
request = arg_dict.get(k)
break
del arg_dict
del arginfo
if(request):
break
return request
except Exception as e:
print e
return None
pass
@Verurteilt
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment