X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=ldapdb%2Frouter.py;fp=ldapdb%2Frouter.py;h=7e3ff4ace93112d8b7d2c38b27f7d31d99282a5d;hp=38dfdb06b64ab16143da31189665a2bebcde47d8;hb=50d3fcb1ad4326a55bb156fd641ce40bf52a9a51;hpb=ad7b10181730ec4888d4537256ef1c5202b564c4 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