Created
December 3, 2012 17:05
-
-
Save dinopetrone/4196375 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MasterSlaveRouter(object): | |
def db_for_read(self, model, **hints): | |
return 'slave' | |
def db_for_write(self, model, **hints): | |
return 'master' | |
def allow_relation(self, obj1, obj2, **hints): | |
db_list = ('master', 'slave') | |
if obj1.state.db in db_list and obj2.state.db in db_list: | |
return True | |
return None | |
def allow_syncdb(self, db, model): | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment