Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine: Production versus Development Settings

How do you setup a settings file? One is for your local development server and another set of setting values for when you upload to Google App Engine?

For example, I would like to set up a settings file where I store the Absolute Root URL.

like image 361
TimLeung Avatar asked May 17 '09 05:05

TimLeung


2 Answers

It's not clear from your question if you're asking about the Java or Python runtime. I'll assume Python for now.

Just like any other Python webapp, the settings file can be wherever and whatever you want. I usually use a .py file called 'settings.py' or 'config.py' in the root directory of my app. For example, see Bloog's settings file.

As far as having different settings for production and development goes, you have two options:

  1. Simply keep two branches in your source code repository, one for dev and one for prod, and periodically merge from dev to prod when you want to do a release. In this case, you just don't merge config.py.
  2. Autodetect which platform you're running on, and apply settings as appropriate. The easiest way to do this is to check the value of os.environ['SERVER_SOFTWARE'], which will start with 'Dev' if it's the development server. You can use this to set a flag like so:

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

like image 174
Nick Johnson Avatar answered Oct 26 '22 18:10

Nick Johnson


You can find out the root URL from the request, and use that instead of configuring it manually. Or if you need further configuration, then use that to decide which config to use.

like image 24
Kevin Reid Avatar answered Oct 26 '22 16:10

Kevin Reid