From 50d3fcb1ad4326a55bb156fd641ce40bf52a9a51 Mon Sep 17 00:00:00 2001 From: jlaine Date: Mon, 11 Apr 2011 12:57:03 +0000 Subject: [PATCH] rework router git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@1038 e071eeec-0327-468d-9b6a-08194a12b294 --- ldapdb/router.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ldapdb/router.py b/ldapdb/router.py index 38dfdb0..7e3ff4a 100644 --- a/ldapdb/router.py +++ b/ldapdb/router.py @@ -32,21 +32,23 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +def is_ldap_model(model): + # FIXME: there is probably a better check than testing 'base_dn' + return hasattr(model, 'base_dn') + class Router(object): """A router to control all database operations on models in the myapp application""" def db_for_read(self, model, **hints): "Point all operations on LDAP models to 'ldap'" - from ldapdb.models import Model - if Model in model.__bases__: + if is_ldap_model(model): return 'ldap' return None def db_for_write(self, model, **hints): "Point all operations on LDAP models to 'ldap'" - from ldapdb.models import Model - if Model in model.__bases__: + if is_ldap_model(model): return 'ldap' return None -- 2.30.2