Whilst developing I want to handle some things slight differently than I will when I eventually upload to the Google servers.
Is there a quick test that I can do to find out if I'm in the SDK or live?
Whilst developing I want to handle some things slight differently than I will when I eventually upload to the Google servers.
Is there a quick test that I can do to find out if I'm in the SDK or live?
See: http://code.google.com/appengine/docs/python/runtime.html#The_Environment
The following environment variables are part of the CGI standard, with special behavior in App Engine:
SERVER_SOFTWARE
:In the development web server, this value is "
Development/X.Y
" where "X.Y
" is the version of the runtime.When running on App Engine, this value is "
Google App Engine/X.Y.Z
".
Based on the same trick, I use this function in my code:
def isLocal():
return os.environ["SERVER_NAME"] in ("localhost", "www.lexample.com")
I have customized my /etc/hosts
file in order to be able to access the local version by prepending a "l" to my domain name, that way it is really easy to pass from local to production.
Example:
www.example.com
www.lexample.com