X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=ldapdb%2Fmodels%2Fbase.py;h=9291c6b122656dc4b08e92db20dc30928d22bc28;hp=a0ade49ea87d631cac2eb089685b48d65ca9b6c9;hb=1fb23bec834636d0427e7ac6db92639c133ef1d2;hpb=bb0d161101fe9f6fde920db23482b1e1b8e7b904 diff --git a/ldapdb/models/base.py b/ldapdb/models/base.py index a0ade49..9291c6b 100644 --- a/ldapdb/models/base.py +++ b/ldapdb/models/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # django-ldapdb -# Copyright (C) 2009 Bolloré telecom +# Copyright (C) 2009-2010 Bolloré telecom # See AUTHORS file for a full list of contributors. # # This program is free software: you can redistribute it and/or modify @@ -18,8 +18,6 @@ # along with this program. If not, see . # -# -*- coding: utf-8 -*- - import ldap import logging @@ -34,8 +32,6 @@ class ModelBase(django.db.models.base.ModelBase): Metaclass for all LDAP models. """ def __new__(cls, name, bases, attrs): - attr_meta = attrs.pop('Ldap', None) - super_new = super(ModelBase, cls).__new__ new_class = super_new(cls, name, bases, attrs) @@ -46,10 +42,6 @@ class ModelBase(django.db.models.base.ModelBase): new_class.objects.get_query_set = get_query_set new_class._default_manager.get_query_set = get_query_set - if attr_meta: - new_class._meta.dn = attr_meta.dn - new_class._meta.object_classes = attr_meta.object_classes - return new_class class Model(django.db.models.base.Model): @@ -107,7 +99,7 @@ class Model(django.db.models.base.Model): continue value = getattr(self, field.name) if value: - entry.append((field.db_column, value)) + entry.append((field.db_column, field.get_db_prep_save(value, connection=ldapdb.connection))) logging.debug("Creating new LDAP entry %s" % new_dn) ldapdb.connection.add_s(new_dn, entry) @@ -127,7 +119,7 @@ class Model(django.db.models.base.Model): new_value = getattr(self, field.name, None) if old_value != new_value: if new_value: - modlist.append((ldap.MOD_REPLACE, field.db_column, new_value)) + modlist.append((ldap.MOD_REPLACE, field.db_column, field.get_db_prep_save(new_value, connection=ldapdb.connection))) elif old_value: modlist.append((ldap.MOD_DELETE, field.db_column, None))