Friday, June 13, 2008

Ruby on Rails vs (Python on) Django: A Comparison (Part 4)

In both Rails and Django, a project has a small collection of settings files that define some constants like the database connection parameters the application will use, which modules external to the project will be imported, which modules internal to the project will be enabled, and so on.

In Django, these files are written in pure Python and live in a project's root directory. Rails uses both Ruby and YAML (hint, it's a recursive acronym and the M and L stand for "markup language") for config files, which live in a 'config' directory under the project root.

Many settings may be specified independently for different configurations. For example, in a development configuration, you'd connect to a local database containing meaningless data for the purpose of testing, and set a debug flag to "on" to get a detailed stack trace whenever an unhandled exception brings things to a halt. In a production configuration you'd point the database parameters to the production database with all the application's real, live data, and make sure the debug setting is "off" so that an error tells an end user something like, "500 Internal Server Error" rather than something which may be potentially helpful to an attacker, such as a stack trace. One nice thing about using a framework is the fact that others have thought of all these things, so you don't need to remember them all each time you start a new project!

This post is rather thin; I realize that. I plan to fill in more detail later as I use the frameworks more and important differences are brought to my attention.

Next, we'll talk about specifying models and synchronizing them with a database schema.