Moving udd to django

James Westby jw+debian at jameswestby.net
Sat Dec 10 02:10:48 UTC 2011


Hi,

I think there are a few reasons that we should consider moving udd to
django (more on what this actually means later.)

  1. We want to have remote commands so that we don't have to ssh in and
  run scripts for common tasks

  2. There are scripts in cron that generate html pages that are
  served. It would be nice to have these generated on request so that
  there is no latency.

  3. It would also allow for starting to move udd to an SOA, or at least
  make it easier.

  4. It would be nice to have a query builder, rather than all the
  hand-written sql.

So, what exactly do I mean by moving to django?

  * Moving all database access to go through django's ORM.

  * Moving all HTML generation to be done in django views.

This has fairly wide-ranging consequences though, and obviously needs to
be broken down in to manageable steps.

Here's my idea for what those steps should be.

1) Install python-django in production
   - So that it is there when it is needed.

2) Create a django project in the udd codebase.
   - Providing the skeleton to use, but not actually changing any
   behaviour

3) Write django management commands for each current script that call
the same code.
   - This gets them running in the django env, but without changing
   anything else.
   - At this point we'll want to deploy, and change the init script and
   cronjobs to run the new scripts.

4) Configure the django project to use multiple databases corresponding
to the existing database.
   - At this point we'll want to deploy and run some sanity checks to
   make sure that django can read the dbs.

5) Pick a db table and write a django model to match. Convert users of
that table to call through the query builder. Repeat.
   - I think this will be ok table-at-a-time, but we should obviously
   test well.

6) At this point we'll be using django just as an ORM, but can turn on
the admin site if we want.

7) We can also start to write django views to replace the
html-generating scripts. Once they are written we can deploy and request
that apache actually run django and serve the views, and then turn of
the scripts.

8) Then we'll be able to start adding forms to the views to accomplish
common tasks.

That's a fairly long road, but it is incremental, and the changed code
deployed at each point can be fairly small.

What do you think? Is this worth doing?

Thanks,

James



More information about the ubuntu-distributed-devel mailing list