1 |
|
---|
2 | class WallDBRouter(object):
|
---|
3 | """The db router for thewall classes"""
|
---|
4 | def __init__(self):
|
---|
5 | self.db_list = ('default','slave')
|
---|
6 |
|
---|
7 | def db_for_read(self, model, **hints):
|
---|
8 | """set to default for now so unit tests will pass"""
|
---|
9 | return 'slave'
|
---|
10 |
|
---|
11 | def db_for_write(self, model, **hints):
|
---|
12 | return 'default'
|
---|
13 |
|
---|
14 | def allow_relation(self, obj1, obj2, **hints):
|
---|
15 | "Allow any relation between two objects in the db pool"
|
---|
16 | if obj1._state.db in self.db_list and obj2._state.db in self.db_list:
|
---|
17 | return True
|
---|
18 | return None
|
---|
19 |
|
---|
20 | def allow_syncdb(self, db, model):
|
---|
21 | """We are the last db, so default to yes"""
|
---|
22 | return db == 'default'
|
---|