def find_request():
	'''
	Inspect running environment for request object. There should be one,
	but don't rely on it.
	'''
	frame = inspect.currentframe()
	request = None
	f = frame

	while not request and f:
		if 'request' in f.f_locals and isinstance(f.f_locals['request'], HttpRequest):
			request = f.f_locals['request']
		f = f.f_back

	del frame
	return request