summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJames Bennett <james@b-list.org>2012-09-08 16:08:01 -0400
committerJames Bennett <james@b-list.org>2012-09-08 16:08:01 -0400
commit408c10e541440b078ccf5d6fcb3f344b7a94d048 (patch)
treeddd7243a815a1431a405d47d4a923424146e6ad8 /docs
parent5d1f09f450686c53ead6f2784ba5c94ea6dccf36 (diff)
Untabify multi-db docs.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/multi-db.txt108
1 files changed, 54 insertions, 54 deletions
diff --git a/docs/topics/db/multi-db.txt b/docs/topics/db/multi-db.txt
index ef9c5a2648..82218692d8 100644
--- a/docs/topics/db/multi-db.txt
+++ b/docs/topics/db/multi-db.txt
@@ -242,41 +242,41 @@ send queries for the ``auth`` app to ``auth_db``::
A router to control all database operations on models in the
auth application.
"""
- def db_for_read(self, model, **hints):
- """
- Attempts to read auth models go to auth_db.
- """
- if model._meta.app_label == 'auth':
- return 'auth_db'
- return None
+ def db_for_read(self, model, **hints):
+ """
+ Attempts to read auth models go to auth_db.
+ """
+ if model._meta.app_label == 'auth':
+ return 'auth_db'
+ return None
- def db_for_write(self, model, **hints):
- """
- Attempts to write auth models go to auth_db.
- """
- if model._meta.app_label == 'auth':
- return 'auth_db'
- return Non
+ def db_for_write(self, model, **hints):
+ """
+ Attempts to write auth models go to auth_db.
+ """
+ if model._meta.app_label == 'auth':
+ return 'auth_db'
+ return Non
- def allow_relation(self, obj1, obj2, **hints):
- """
- Allow relations if a model in the auth app is involved.
- """
- if obj1._meta.app_label == 'auth' or \
+ def allow_relation(self, obj1, obj2, **hints):
+ """
+ Allow relations if a model in the auth app is involved.
+ """
+ if obj1._meta.app_label == 'auth' or \
obj2._meta.app_label == 'auth':
- return True
- return None
+ return True
+ return None
- def allow_syncdb(self, db, model):
- """
- Make sure the auth app only appears in the 'auth_db'
- database.
- """
- if db == 'auth_db':
- return model._meta.app_label == 'auth'
- elif model._meta.app_label == 'auth':
- return False
- return None
+ def allow_syncdb(self, db, model):
+ """
+ Make sure the auth app only appears in the 'auth_db'
+ database.
+ """
+ if db == 'auth_db':
+ return model._meta.app_label == 'auth'
+ elif model._meta.app_label == 'auth':
+ return False
+ return None
And we also want a router that sends all other apps to the
master/slave configuration, and randomly chooses a slave to read
@@ -286,32 +286,32 @@ from::
class MasterSlaveRouter(object):
def db_for_read(self, model, **hints):
- """
- Reads go to a randomly-chosen slave.
- """
- return random.choice(['slave1', 'slave2'])
+ """
+ Reads go to a randomly-chosen slave.
+ """
+ return random.choice(['slave1', 'slave2'])
- def db_for_write(self, model, **hints):
- """
- Writes always go to master.
- """
- return 'master'
+ def db_for_write(self, model, **hints):
+ """
+ Writes always go to master.
+ """
+ return 'master'
- def allow_relation(self, obj1, obj2, **hints):
- """
- Relations between objects are allowed if both objects are
- in the master/slave pool.
- """
- db_list = ('master', 'slave1', 'slave2')
- if obj1.state.db in db_list and obj2.state.db in db_list:
- return True
- return None
+ def allow_relation(self, obj1, obj2, **hints):
+ """
+ Relations between objects are allowed if both objects are
+ in the master/slave pool.
+ """
+ db_list = ('master', 'slave1', 'slave2')
+ if obj1.state.db in db_list and obj2.state.db in db_list:
+ return True
+ return None
- def allow_syncdb(self, db, model):
- """
- All non-auth models end up in this pool.
- """
- return True
+ def allow_syncdb(self, db, model):
+ """
+ All non-auth models end up in this pool.
+ """
+ return True
Finally, in the settings file, we add the following (substituting
``path.to.`` with the actual python path to the module(s) where the