summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'python/www/router.py')
-rw-r--r--python/www/router.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/www/router.py b/python/www/router.py
new file mode 100644
index 0000000..aab4cf9
--- /dev/null
+++ b/python/www/router.py
@@ -0,0 +1,31 @@
+# Copyright 1998-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+class GosbsRouter(object):
+ def db_for_read(self, model, **hints):
+ "Point all operations on zobcs models to 'zobcs'"
+ if model._meta.app_label == 'www':
+ return 'default'
+ return 'gosbs'
+
+ def db_for_write(self, model, **hints):
+ "Point all operations on zobcs models to 'zobcs'"
+ if model._meta.app_label == 'www':
+ return 'default'
+ return 'gosbs'
+
+ def allow_relation(self, obj1, obj2, **hints):
+ "Allow any relation if a both models in zobcs app"
+ if obj1._meta.app_label == 'www' and obj2._meta.app_label == 'www':
+ return True
+ # Allow if neither is zobcs app
+ elif 'www' not in [obj1._meta.app_label, obj2._meta.app_label]:
+ return True
+ return False
+
+ def allow_migrate(self, db, app_label, model_name=None, **hints):
+ if db == 'gosbs':
+ return app_label == 'gosbs'
+ elif app_label == 'gosbs':
+ return False
+ return True