X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;ds=sidebyside;f=ldapdb%2Fmodels%2Fbase.py;h=41d00e8c684b3fa7483973a5478b888808cce290;hb=c15d0f62f8b92e9a2c69d9b93ded4cf964ef710c;hp=a0ade49ea87d631cac2eb089685b48d65ca9b6c9;hpb=bb0d161101fe9f6fde920db23482b1e1b8e7b904;p=matthijs%2Fupstream%2Fdjango-ldapdb.git diff --git a/ldapdb/models/base.py b/ldapdb/models/base.py index a0ade49..41d00e8 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): @@ -68,6 +60,12 @@ class Model(django.db.models.base.Model): super(Model, self).__init__(*args, **kwargs) self.saved_pk = self.pk + def _collect_sub_objects(self, collector): + """ + This private API seems to be called by the admin interface in django 1.2 + """ + pass + def build_rdn(self): """ Build the Relative Distinguished Name for this entry. @@ -107,7 +105,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 +125,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))