Get The Request Uri Outside Of A Requesthandler In Google App Engine (python)
So, within a webapp.RequestHandler subclass I would use self.request.uri to get the request URI. But, I can't access this outside of a RequestHandler and so no go. Any ideas? I'm r
Solution 1:
You should generally be doing everything within some sort of RequestHandler or the equivalent in your non-WebApp framework. However, if you really insist on being stuck in the early 1990s and writing plain CGI scripts, the environment variables SERVER_NAME and PATH_INFO may be what you want; see a CGI reference for more info.
Solution 2:
Since using request outside code handling it is meaningless I assume you'd like to access it from some method called by handler without passing request to it. Your choices are:
- Refactor code so that request is passed to it.
- When the former is not possible use a hack by defining a global
threading.local()
, storing request somewhere in request handler and access it in your method.
Post a Comment for "Get The Request Uri Outside Of A Requesthandler In Google App Engine (python)"