Wednesday, May 5, 2010

Can I map authenticated users to specific databases via a database Router?

I'm trying to port part of an existing application to Django. In the
other application, each user has their data stored on separate
databases with identical schemas.

For example, if we have users A, B and C, there are 3 databases
("DatabaseA", "DatabaseB", "DatabaseC") each having two tables:
blog_entries and blog_comments

Ideally I'd like to write a single application into which all 3 users
can login in. From here on out, all of the interactions with the
database should be routed to database specific to that user. That is
to say, UserA should only ever be able to insert and update data in
DatabaseA and UserB should only be able to access DatabaseB.

From a coding perspective, I'd like to leverage Django's multiple
database support and implement this routing via the DATABASE_ROUTERS
setting or as a ModelManager so that database I'm accessing abstracted
away from the code. That is to say, I can write
BlogEntries.objects.all() and always return only those blog entries
for the currently authenticated user.

Is this type of routing or model management possible with Django?
Should I consider using a site-specific settings.py file simpler to
what's discussed here: http://www.huyng.com/archives/franchising-running-multiple-sites-from-one-django-codebase-2/394/

Thank you
Parker

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate