From: jlaine Date: Mon, 11 Apr 2011 12:57:03 +0000 (+0000) Subject: rework router X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=commitdiff_plain;h=50d3fcb1ad4326a55bb156fd641ce40bf52a9a51 rework router git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@1038 e071eeec-0327-468d-9b6a-08194a12b294 --- 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