App.yaml vs Settings.py

I’m really about to geek out on you — I’m going to (complain) compare the Google App Engine configuration file (app.yaml) to the Django setting.py.

Simon Wilson of OpenID and django-openid fame wrote a post on logging in Django and got me thinking a long these lines.

App.yaml sucks. Why? Because it’s not really “pythonic” and I can’t write little bits of python code to make configuration any easier.

For example if wanted to stick and API key in settings.py and wanted a different one for development I could easily do something like

if DEBUG:
  MY_KEY = '123'
else:
  MY_KEY = 'ABC'

Unfortunately Google decided to go with a stricter separation of concerns — at the cost of flexibility.

This is also partly what is wrong with Java. When is the last time you configured a serious Java applications without editing *atleast* one (if you are lucky) xml file (or more if you are not).

  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Reddit

  • Your app.yaml and your settings.py are really quite different. If you are using django on appengine these two will be treated differently.

    You can think of the app.yaml as your webserver configuration. The web server can serve static files do many things much faster if it doesn't have to invoke your application python code. It that way it's best to set your static file urls and caching expriation in your app.yaml file rather than your urls.py or settings.py or views. This is the same for deploying a django app with lighty or apache.

    In terms of the debug in development versus production, I think the best practice there is to make a deploy directory which contains a deploy.py to write an app.yaml file out for production or local development. You can use python's built in string.Template module for that. You'll want to add the deploy/ directory to skip_files in your app.yaml so it isn't deployed to production though.
  • Gorodn Clarke
    Hi searching he web found your details online and have a number of customers that are looking to re-develop their HTML, PHP website to Django/Python. I am a Business Development Consultant and looking to team up with other Django/Python so that I can resell their skills and channel my customer projects via our website to them. Please feel free to get in touch via Skype: G.J.G.Clarke
blog comments powered by Disqus