File: 0003-Use-get_attname-instead-of-attname-attribute.patch

package info (click to toggle)
django-ldapdb 1.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 440 kB
  • sloc: python: 1,994; makefile: 40
file content (45 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: dzen <benoit.calvez@polyconseil.fr>
Date: Tue, 13 Apr 2021 16:46:32 +0200
Subject: Use get_attname instead of attname attribute

Forwarded: not-needed
---
 ldapdb/backends/ldap/compiler.py | 4 ++--
 ldapdb/models/base.py            | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ldapdb/backends/ldap/compiler.py b/ldapdb/backends/ldap/compiler.py
index 4ce9f94..1d9e771 100644
--- a/ldapdb/backends/ldap/compiler.py
+++ b/ldapdb/backends/ldap/compiler.py
@@ -231,7 +231,7 @@ class SQLCompiler(compiler.SQLCompiler):
                 if isinstance(e[0], aggregates.Count):
                     value = 0
                     input_field = e[0].get_source_expressions()[0].field
-                    if input_field.attname == 'dn':
+                    if input_field.get_attname() == 'dn':
                         value = 1
                     elif hasattr(input_field, 'from_ldap'):
                         result = input_field.from_ldap(
@@ -243,7 +243,7 @@ class SQLCompiler(compiler.SQLCompiler):
                                 value = len(result)
                     row.append(value)
                 else:
-                    if e[0].field.attname == 'dn':
+                    if e[0].field.get_attname() == 'dn':
                         row.append(dn)
                     elif hasattr(e[0].field, 'from_ldap'):
                         row.append(e[0].field.from_ldap(
diff --git a/ldapdb/models/base.py b/ldapdb/models/base.py
index e4d9e15..18d3d1e 100644
--- a/ldapdb/models/base.py
+++ b/ldapdb/models/base.py
@@ -83,7 +83,7 @@ class Model(django.db.models.base.Model):
             ]
 
         def get_field_value(field, instance):
-            python_value = getattr(instance, field.attname)
+            python_value = getattr(instance, field.get_attname())
             return field.get_db_prep_save(python_value, connection=connection)
 
         if create: