Saturday, January 30, 2010

App Engine: Am I running on the development server?

Sometimes you need to determine within your application whether it is currently running in a development or production environment. I just spotted a tip from Nickolas Daskalou in the Google App Engine Python forums that allows you to do just that:


import os
...
debug = os.environ['SERVER_SOFTWARE'].startswith('Dev')


This isn't particularly exciting, but I know I will come across this situation soon so I thought I would note the solution for myself in the future. Thanks Nick!

The Google App Engine development environment is generally pretty safe for Google specific resources: no emails are actually sent, only the local datastore can be updated and task queues do not process without manual intervention. When working with external resources, such as read/write web services, however, you may want to limit what your application does within a development.

No comments:

Post a Comment