Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Untabify multi-db docs.

  • Loading branch information...
commit 408c10e541440b078ccf5d6fcb3f344b7a94d048 1 parent 5d1f09f
James Bennett authored

Showing 1 changed file with 60 additions and 60 deletions. Show diff stats Hide diff stats

  1. 120  docs/topics/db/multi-db.txt
120  docs/topics/db/multi-db.txt
@@ -242,41 +242,41 @@ send queries for the ``auth`` app to ``auth_db``::
242 242
         A router to control all database operations on models in the
243 243
         auth application.
244 244
         """
245  
-	def db_for_read(self, model, **hints):
246  
-	    """
247  
-	    Attempts to read auth models go to auth_db.
248  
-	    """
249  
-	    if model._meta.app_label == 'auth':
250  
-	        return 'auth_db'
251  
- 	    return None
252  
-
253  
-	def db_for_write(self, model, **hints):
254  
-	    """
255  
-	    Attempts to write auth models go to auth_db.
256  
-	    """
257  
-	    if model._meta.app_label == 'auth':
258  
-	        return 'auth_db'
259  
-	    return Non
260  
-
261  
-	def allow_relation(self, obj1, obj2, **hints):
262  
-	    """
263  
-	    Allow relations if a model in the auth app is involved.
264  
-	    """
265  
-	    if obj1._meta.app_label == 'auth' or \
  245
+        def db_for_read(self, model, **hints):
  246
+            """
  247
+            Attempts to read auth models go to auth_db.
  248
+            """
  249
+            if model._meta.app_label == 'auth':
  250
+                return 'auth_db'
  251
+            return None
  252
+
  253
+        def db_for_write(self, model, **hints):
  254
+            """
  255
+            Attempts to write auth models go to auth_db.
  256
+            """
  257
+            if model._meta.app_label == 'auth':
  258
+                return 'auth_db'
  259
+            return Non
  260
+
  261
+        def allow_relation(self, obj1, obj2, **hints):
  262
+            """
  263
+            Allow relations if a model in the auth app is involved.
  264
+            """
  265
+            if obj1._meta.app_label == 'auth' or \
266 266
                obj2._meta.app_label == 'auth':
267  
-	       return True
268  
-	    return None
269  
-
270  
-	def allow_syncdb(self, db, model):
271  
-	    """
272  
-	    Make sure the auth app only appears in the 'auth_db'
273  
-	    database.
274  
-	    """
275  
-	    if db == 'auth_db':
276  
-	        return model._meta.app_label == 'auth'
277  
-	    elif model._meta.app_label == 'auth':
278  
-	        return False
279  
-	    return None
  267
+               return True
  268
+            return None
  269
+
  270
+        def allow_syncdb(self, db, model):
  271
+            """
  272
+            Make sure the auth app only appears in the 'auth_db'
  273
+            database.
  274
+            """
  275
+            if db == 'auth_db':
  276
+                return model._meta.app_label == 'auth'
  277
+            elif model._meta.app_label == 'auth':
  278
+                return False
  279
+            return None
280 280
 
281 281
 And we also want a router that sends all other apps to the
282 282
 master/slave configuration, and randomly chooses a slave to read
@@ -286,32 +286,32 @@ from::
286 286
 
287 287
     class MasterSlaveRouter(object):
288 288
         def db_for_read(self, model, **hints):
289  
-	    """
290  
-	    Reads go to a randomly-chosen slave.
291  
-	    """
292  
-	    return random.choice(['slave1', 'slave2'])
293  
-
294  
-	def db_for_write(self, model, **hints):
295  
-	    """
296  
-	    Writes always go to master.
297  
-	    """
298  
-	    return 'master'
299  
-
300  
-	def allow_relation(self, obj1, obj2, **hints):
301  
-	    """
302  
-	    Relations between objects are allowed if both objects are
303  
-	    in the master/slave pool.
304  
-	    """
305  
-	    db_list = ('master', 'slave1', 'slave2')
306  
-	    if obj1.state.db in db_list and obj2.state.db in db_list:
307  
-	        return True
308  
-	    return None
309  
-
310  
-	def allow_syncdb(self, db, model):
311  
-	    """
312  
-	    All non-auth models end up in this pool.
313  
-	    """
314  
-	    return True
  289
+            """
  290
+            Reads go to a randomly-chosen slave.
  291
+            """
  292
+            return random.choice(['slave1', 'slave2'])
  293
+
  294
+        def db_for_write(self, model, **hints):
  295
+            """
  296
+            Writes always go to master.
  297
+            """
  298
+            return 'master'
  299
+
  300
+        def allow_relation(self, obj1, obj2, **hints):
  301
+            """
  302
+            Relations between objects are allowed if both objects are
  303
+            in the master/slave pool.
  304
+            """
  305
+            db_list = ('master', 'slave1', 'slave2')
  306
+            if obj1.state.db in db_list and obj2.state.db in db_list:
  307
+                return True
  308
+            return None
  309
+
  310
+        def allow_syncdb(self, db, model):
  311
+            """
  312
+            All non-auth models end up in this pool.
  313
+            """
  314
+            return True
315 315
 
316 316
 Finally, in the settings file, we add the following (substituting
317 317
 ``path.to.`` with the actual python path to the module(s) where the

0 notes on commit 408c10e

Please sign in to comment.
Something went wrong with that request. Please try again.