Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created September 13, 2011 16:04
Show Gist options
  • Save jacobian/1214211 to your computer and use it in GitHub Desktop.
Save jacobian/1214211 to your computer and use it in GitHub Desktop.
"""
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