Created
September 13, 2011 16:04
-
-
Save jacobian/1214211 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
""" | |
DB router for Trac. Very simple: just makes sure that all Trac tables are | |
queries against the "trac" DB alias. | |
It's very simplistic, leaving off allow_relation and allow_syncdb since all | |
the Trac apps are unmanaged. | |
""" | |
from unipath import FSPath as Path | |
THIS_APP = Path(__file__).parent.name | |
class TracRouter(object): | |
def db_for_read(self, model, **hints): | |
return 'trac' if app_label(model) == THIS_APP else None | |
def db_for_write(self, model, **hints): | |
return 'trac' if app_label(model) == THIS_APP else None | |
def app_label(model): | |
return model._meta.app_label |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment