Hello,

I am attempting to use a database router to move django.contrib.auth
off to its own database.   Reasoning behind this - I want to share
just a few tables ( Auth and a custom app called AdminAccess )  across
multiple sites which might be on multiple servers not sharing a single
codebase.    Basically allowing me to have separate sites with a
single sign on.    The AdminAccess app basically makes it where a user
who is_staff on one domain can't access the staff panel on another
site without permission.

I put in the router and wrote a custom admin backend and managed to
get the changes in the admin interface to change the users in the new
database.   The problem I had was it complained about
django_content_type not being in the same table.    I copied it over -
but I fear it might be needed by a few other things in the admin
backend.    Is it?   Will it hurt to move it?    Is there an easier
way to do this?    I don't want to hack django to the point where it's
an epic pain to update.    I'd like to do this as easy as
possible.


Here is the router i'm using.

class AuthRouter(object):

    def db_for_read(self, model, **hints):
        "Point all operations on auth models to 'users'"
        if model._meta.app_label == 'auth.User':
            return 'users'
        return None

    def db_for_write(self, model, **hints):
        "Point all operations on auth models to 'users'"
        if model._meta.app_label == 'auth.User':
            return 'users'
        return None

    def allow_relation(self, obj1, obj2, **hints):
        "Allow any relation if a model in auth is involved"
        if obj1._meta.app_label == 'auth.User' or obj2._meta.app_label
== 'auth.User':
            return True
        return None

    def allow_syncdb(self, db, model):
        "Make sure the auth app only appears on the 'users' db"
        if db == 'users':
            return model._meta.app_label == 'auth.User'
        elif model._meta.app_label == 'auth.User':
            return False
        return None



Thanks!

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

Reply via email to