views:

72

answers:

3

Brand new to django. We have a legacy django project using django 0.96x that does authentication, ldap, etc., and it's pretty involved so we don't want to rewrite that code.

We want to add a forum solution (off the shelf) but all of the ones I've seen so far require django 1.x

I'm trying to figure out how to get this working and I've narrowed it down to the following:

  1. Use an old forum solution that works w/django 0.96 (does this exist?)
  2. Try to patch a forum solution to make it "backwards compatible" with 0.96 (possible nightmare)
  3. Use two different djangos: 0.96 and 1.x and (since we're using Apache w/mod_python) have two different Location directives; adjust PYTHONPATH for each appropriately (or use virtualenv, etc.)

But will option #3 even work? I don't know enough about how django.contrib.auth and friends work so if I run two different versions of django will the user stay logged in? I didn't mention trying to patch our 0.96 project to bring it to 1.x but we don't really have the time to do that.

Any suggestions?

A: 

A user's login status is stored using sessions. As far as I can tell from comparing trunk to the 0.96 source, the sessions are committed to a cookie the same way, and auth stores the user ID and backend the same way, so as long as the two apps use the same session storage and are on the same domain, it should work. (Just to be safe, I wouldn't use secure cookies in case the backend logic has changed - I didn't check out that part.)

However, 0.96 did not feature pluggable session stores like modern Django does. Probably, to get a current version of Django to work with your 0.96 sessions, you would need to write a session backend for the current Django that connects to the 0.96 database and manipulates the sessions there. I'm not sure how well that would work, though.

LeafStorm
+1  A: 

It's possible, but it may be pretty painful to do option #3.

How about Option 4: bite the bullet and upgrade to Django 1.1.1. I did this with a couple of 0.97pre sites and it took less time than I thought it would. The biggest pain was dealing with admin stuff. Instead of going with separate admin.py files, we simply put the Admin classes directly below the Model classes.

I use Mercurial for my DVCS and I just cloned, hacked, merged and it worked. It took about 3-5 hours per site and that included some custom template tag munging.

Peter Rowell
Yeah, we may have no other choice but to do this ;-)
Rob
A: 

It's possible to expose Django 0.96 tables to 1.1 - you can use unmanaged models wrapped around database VIEWs. In other words you issue:

CREATE VIEW auth_user AS SELECT * from django096db.auth_user; (and similar cmd for other tables)

and then you have Django 1.1 synchronized with 0.96 (assuming 0.96 tables are compatible with 1.1, I haven't checked that).

Tomasz Zielinski