X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=ldapdb%2Frouter.py;h=4da0c253a2bbe93e73b6d8d125425620ca0cd8d0;hp=38dfdb06b64ab16143da31189665a2bebcde47d8;hb=3e119b381a67261e2b70646117f29bd799c776c1;hpb=a8b0461245e7365b4c9662ea0f10c3f2d5b4b41f diff --git a/ldapdb/router.py b/ldapdb/router.py index 38dfdb0..4da0c25 100644 --- a/ldapdb/router.py +++ b/ldapdb/router.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # django-ldapdb -# Copyright (c) 2009-2010, Bolloré telecom +# Copyright (c) 2009-2011, Bolloré telecom # All rights reserved. # # See AUTHORS file for a full list of contributors. @@ -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