Codebase list django-ldapdb / cab720d
New upstream version 1.5.1 Michael Fladischer 3 years ago
27 changed file(s) with 374 addition(s) and 203 deletion(s). Raw diff Collapse all Expand all
+0
-7
.flake8 less more
0 [flake8]
1
2 max-line-length = 120
3 # W503: 'and' on start of line
4 ignore = W503
5
6 ; vim:set ft=dosini:
00 ChangeLog
11 =========
2
3 1.5.1 (2020-10-12)
4 ------------------
5
6 *Bugfix:*
7
8 * Fix empty wheel (missing nested code)
9
10
11 1.5.0 (2020-10-10)
12 ------------------
13
14 *New:*
15
16 * Add support for Django >= 3.1
17
18 *Removed:*
19
20 * Drop support for Django < 2.2
21 * Drop support for Python < 3.6
22
223
324 1.4.0 (2019-07-11)
425 ------------------
00 include AUTHORS ChangeLog CODE_OF_CONDUCT.md CONTRIBUTING.rst LICENSE README.rst
1 include requirements*.txt
21
32 graft ldapdb
43 graft tests
76 global-exclude *.py[cod] __pycache__ .*swp
87 prune .github
98
10 include Makefile manage_dev.py tox.ini .flake8
9 include Makefile manage_dev.py tox.ini
66 -Wignore::PendingDeprecationWarning:imp \
77 -Wignore::DeprecationWarning:imp \
88 -Wignore::PendingDeprecationWarning:distutils \
9 -Wignore::DeprecationWarning:distutils
9 -Wignore::DeprecationWarning:distutils \
10 -Wignore::ImportWarning:
1011
1112 default:
1213
1314 install:
14
1515 python setup.py install
1616
1717 clean:
1919 find . -type f -path '*/__pycache__/*' -delete
2020 find . -type d -empty -delete
2121
22 update:
22 upgrade:
2323 pip install --upgrade pip setuptools
24 pip install -r requirements_dev.txt
24 pip install --upgrade -e .[dev]
2525 pip freeze
2626
2727 release:
2828 fullrelease
2929
3030
31 .PHONY: default install clean update release
31 .PHONY: default install clean upgrade release
3232
3333 testall:
3434 tox
4141 lint: flake8 isort check-manifest
4242
4343 flake8:
44 flake8 --config .flake8 $(PACKAGE) $(TESTS_DIR)
44 flake8 $(PACKAGE) $(TESTS_DIR)
4545
4646 isort:
47 isort $(PACKAGE) $(TESTS_DIR) --recursive --check-only --diff --project $(PACKAGE) --project $(TESTS_DIR)
47 isort $(PACKAGE) $(TESTS_DIR) --check-only --diff --project $(PACKAGE) --project $(TESTS_DIR)
4848
4949 check-manifest:
5050 check-manifest
0 Metadata-Version: 1.2
0 Metadata-Version: 2.1
11 Name: django-ldapdb
2 Version: 1.4.0
3 Summary: An LDAP database backend for Django
2 Version: 1.5.1
3 Summary: A LDAP database backend for Django
44 Home-page: https://github.com/django-ldapdb/django-ldapdb
5 Author: Jeremy Laine
5 Author: Jeremy Lainé
66 Author-email: jeremy.laine@m4x.org
77 Maintainer: Raphaël Barrois
88 Maintainer-email: raphael.barrois+django-ldapdb@polytechnique.org
4040 * Full admin support and browsing
4141
4242
43 ``django-ldapdb`` supports Django versions 1.11 / 2.1 / 2.2, and Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7,
44 as far as the Django and Python versions are compatible.
43 ``django-ldapdb`` supports every upstream-supported Django version, based on
44 the `Django support policy <https://www.djangoproject.com/download/#supported-versions>`_.
45
46 For the current version, the following versions are supported:
47
48 - Django 2.2 (LTS), under Python 3.6 - 3.8 (Python 3.5 has reached its end of life);
49 - Django 3.0, under Python 3.6 - 3.8;
50 - Django 3.1, under Python 3.6 - 3.8.
4551
4652
4753 Installing django-ldapdb
6369 or install a pre-built version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
6470 (choose the ``.whl`` file matching your Python/Windows combination, and install it with ``pip install python-ldap-3...whl``).
6571
66 and then you can also install ``django-ldapdb`` with
72 You may then install ``django-ldapdb`` with
6773
6874 ``pip install django-ldapdb``
6975
180186 the timeout will be used on each individual request;
181187 the overall processing time might be much higher.
182188
183 Keywords: django,ldap,database
189
190 Developing with a LDAP server
191 -----------------------------
192
193 When developing against a LDAP server, having access to a development LDAP server often proves
194 useful.
195
196 django-ldapdb uses the `volatildap project <https://pypi.org/project/volatildap>`_ for this purpose:
197
198 - A LDAP server is instantiated for each TestClass;
199 - Its content is reset at the start of each test function;
200 - It can be customized to embark any schemas required by the application;
201 - Starting with volatildap 1.4.0, the volatildap server can be controlled remotely, avoiding the need
202 to install a LDAP server on the host.
203
204 Applications using django-ldapdb may use the following code snippet when setting up their tests:
205
206 .. code-block:: python
207
208 # This snippet is released in the Public Domain
209
210 from django.conf import settings
211 from django.test import TestCase
212
213 import volatildap
214
215 class LdapEnabledTestCase(TestCase):
216 @classmethod
217 def setUpClass(cls):
218 super().setUpClass()
219 cls.ldap = volatildap.LdapServer(
220 # Load some initial data
221 initial={'ou=people': {
222 'ou': ['people'],
223 'objectClass': ['organizationalUnit'],
224 }},
225 # Enable more LDAP schemas
226 schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'],
227 )
228 # The volatildap server uses specific defaults, and listens on an arbitrary port.
229 # Copy the server-side values to Django settings
230 settings.DATABASES['ldap']['USER'] = cls.ldap.rootdn
231 settings.DATABASES['ldap']['PASSWORD'] = cls.ldap.rootpw
232 settings.DATABASES['ldap']['NAME'] = cls.ldap.uri
233
234 def setUp(self):
235 super().setUp()
236 # Starting an already-started volatildap server performs a data reset
237 self.ldap.start()
238
239 @classmethod
240 def tearDownClass(cls):
241 # Free up resources on teardown.
242 cls.ldap.stop()
243 super().tearDownClass()
244
245 Keywords: django,ldap,database,ldapdb
184246 Platform: UNKNOWN
185247 Classifier: Development Status :: 5 - Production/Stable
186248 Classifier: Environment :: Web Environment
187 Classifier: Programming Language :: Python
188 Classifier: Programming Language :: Python :: 2.7
189 Classifier: Programming Language :: Python :: 3.4
190 Classifier: Programming Language :: Python :: 3.5
191 Classifier: Programming Language :: Python :: 3.6
192 Classifier: Programming Language :: Python :: 3.7
193 Classifier: Framework :: Django :: 1.11
194 Classifier: Framework :: Django :: 2.0
195 Classifier: Framework :: Django :: 2.1
249 Classifier: Framework :: Django :: 2.2
250 Classifier: Framework :: Django :: 3.0
251 Classifier: Framework :: Django :: 3.1
196252 Classifier: Intended Audience :: Developers
197253 Classifier: Intended Audience :: System Administrators
198254 Classifier: License :: OSI Approved :: BSD License
255 Classifier: Programming Language :: Python
256 Classifier: Programming Language :: Python :: 3.6
257 Classifier: Programming Language :: Python :: 3.7
258 Classifier: Programming Language :: Python :: 3.8
199259 Classifier: Topic :: Internet :: WWW/HTTP
200260 Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
201261 Classifier: Topic :: Software Development :: Libraries :: Python Modules
262 Requires-Python: >=3.6
263 Provides-Extra: dev
3030 * Full admin support and browsing
3131
3232
33 ``django-ldapdb`` supports Django versions 1.11 / 2.1 / 2.2, and Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7,
34 as far as the Django and Python versions are compatible.
33 ``django-ldapdb`` supports every upstream-supported Django version, based on
34 the `Django support policy <https://www.djangoproject.com/download/#supported-versions>`_.
35
36 For the current version, the following versions are supported:
37
38 - Django 2.2 (LTS), under Python 3.6 - 3.8 (Python 3.5 has reached its end of life);
39 - Django 3.0, under Python 3.6 - 3.8;
40 - Django 3.1, under Python 3.6 - 3.8.
3541
3642
3743 Installing django-ldapdb
5359 or install a pre-built version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
5460 (choose the ``.whl`` file matching your Python/Windows combination, and install it with ``pip install python-ldap-3...whl``).
5561
56 and then you can also install ``django-ldapdb`` with
62 You may then install ``django-ldapdb`` with
5763
5864 ``pip install django-ldapdb``
5965
169175 queries (for instance a paginated search yielding thousands of entries),
170176 the timeout will be used on each individual request;
171177 the overall processing time might be much higher.
178
179
180 Developing with a LDAP server
181 -----------------------------
182
183 When developing against a LDAP server, having access to a development LDAP server often proves
184 useful.
185
186 django-ldapdb uses the `volatildap project <https://pypi.org/project/volatildap>`_ for this purpose:
187
188 - A LDAP server is instantiated for each TestClass;
189 - Its content is reset at the start of each test function;
190 - It can be customized to embark any schemas required by the application;
191 - Starting with volatildap 1.4.0, the volatildap server can be controlled remotely, avoiding the need
192 to install a LDAP server on the host.
193
194 Applications using django-ldapdb may use the following code snippet when setting up their tests:
195
196 .. code-block:: python
197
198 # This snippet is released in the Public Domain
199
200 from django.conf import settings
201 from django.test import TestCase
202
203 import volatildap
204
205 class LdapEnabledTestCase(TestCase):
206 @classmethod
207 def setUpClass(cls):
208 super().setUpClass()
209 cls.ldap = volatildap.LdapServer(
210 # Load some initial data
211 initial={'ou=people': {
212 'ou': ['people'],
213 'objectClass': ['organizationalUnit'],
214 }},
215 # Enable more LDAP schemas
216 schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'],
217 )
218 # The volatildap server uses specific defaults, and listens on an arbitrary port.
219 # Copy the server-side values to Django settings
220 settings.DATABASES['ldap']['USER'] = cls.ldap.rootdn
221 settings.DATABASES['ldap']['PASSWORD'] = cls.ldap.rootpw
222 settings.DATABASES['ldap']['NAME'] = cls.ldap.uri
223
224 def setUp(self):
225 super().setUp()
226 # Starting an already-started volatildap server performs a data reset
227 self.ldap.start()
228
229 @classmethod
230 def tearDownClass(cls):
231 # Free up resources on teardown.
232 cls.ldap.stop()
233 super().tearDownClass()
0 Metadata-Version: 1.2
0 Metadata-Version: 2.1
11 Name: django-ldapdb
2 Version: 1.4.0
3 Summary: An LDAP database backend for Django
2 Version: 1.5.1
3 Summary: A LDAP database backend for Django
44 Home-page: https://github.com/django-ldapdb/django-ldapdb
5 Author: Jeremy Laine
5 Author: Jeremy Lainé
66 Author-email: jeremy.laine@m4x.org
77 Maintainer: Raphaël Barrois
88 Maintainer-email: raphael.barrois+django-ldapdb@polytechnique.org
4040 * Full admin support and browsing
4141
4242
43 ``django-ldapdb`` supports Django versions 1.11 / 2.1 / 2.2, and Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7,
44 as far as the Django and Python versions are compatible.
43 ``django-ldapdb`` supports every upstream-supported Django version, based on
44 the `Django support policy <https://www.djangoproject.com/download/#supported-versions>`_.
45
46 For the current version, the following versions are supported:
47
48 - Django 2.2 (LTS), under Python 3.6 - 3.8 (Python 3.5 has reached its end of life);
49 - Django 3.0, under Python 3.6 - 3.8;
50 - Django 3.1, under Python 3.6 - 3.8.
4551
4652
4753 Installing django-ldapdb
6369 or install a pre-built version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
6470 (choose the ``.whl`` file matching your Python/Windows combination, and install it with ``pip install python-ldap-3...whl``).
6571
66 and then you can also install ``django-ldapdb`` with
72 You may then install ``django-ldapdb`` with
6773
6874 ``pip install django-ldapdb``
6975
180186 the timeout will be used on each individual request;
181187 the overall processing time might be much higher.
182188
183 Keywords: django,ldap,database
189
190 Developing with a LDAP server
191 -----------------------------
192
193 When developing against a LDAP server, having access to a development LDAP server often proves
194 useful.
195
196 django-ldapdb uses the `volatildap project <https://pypi.org/project/volatildap>`_ for this purpose:
197
198 - A LDAP server is instantiated for each TestClass;
199 - Its content is reset at the start of each test function;
200 - It can be customized to embark any schemas required by the application;
201 - Starting with volatildap 1.4.0, the volatildap server can be controlled remotely, avoiding the need
202 to install a LDAP server on the host.
203
204 Applications using django-ldapdb may use the following code snippet when setting up their tests:
205
206 .. code-block:: python
207
208 # This snippet is released in the Public Domain
209
210 from django.conf import settings
211 from django.test import TestCase
212
213 import volatildap
214
215 class LdapEnabledTestCase(TestCase):
216 @classmethod
217 def setUpClass(cls):
218 super().setUpClass()
219 cls.ldap = volatildap.LdapServer(
220 # Load some initial data
221 initial={'ou=people': {
222 'ou': ['people'],
223 'objectClass': ['organizationalUnit'],
224 }},
225 # Enable more LDAP schemas
226 schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'],
227 )
228 # The volatildap server uses specific defaults, and listens on an arbitrary port.
229 # Copy the server-side values to Django settings
230 settings.DATABASES['ldap']['USER'] = cls.ldap.rootdn
231 settings.DATABASES['ldap']['PASSWORD'] = cls.ldap.rootpw
232 settings.DATABASES['ldap']['NAME'] = cls.ldap.uri
233
234 def setUp(self):
235 super().setUp()
236 # Starting an already-started volatildap server performs a data reset
237 self.ldap.start()
238
239 @classmethod
240 def tearDownClass(cls):
241 # Free up resources on teardown.
242 cls.ldap.stop()
243 super().tearDownClass()
244
245 Keywords: django,ldap,database,ldapdb
184246 Platform: UNKNOWN
185247 Classifier: Development Status :: 5 - Production/Stable
186248 Classifier: Environment :: Web Environment
187 Classifier: Programming Language :: Python
188 Classifier: Programming Language :: Python :: 2.7
189 Classifier: Programming Language :: Python :: 3.4
190 Classifier: Programming Language :: Python :: 3.5
191 Classifier: Programming Language :: Python :: 3.6
192 Classifier: Programming Language :: Python :: 3.7
193 Classifier: Framework :: Django :: 1.11
194 Classifier: Framework :: Django :: 2.0
195 Classifier: Framework :: Django :: 2.1
249 Classifier: Framework :: Django :: 2.2
250 Classifier: Framework :: Django :: 3.0
251 Classifier: Framework :: Django :: 3.1
196252 Classifier: Intended Audience :: Developers
197253 Classifier: Intended Audience :: System Administrators
198254 Classifier: License :: OSI Approved :: BSD License
255 Classifier: Programming Language :: Python
256 Classifier: Programming Language :: Python :: 3.6
257 Classifier: Programming Language :: Python :: 3.7
258 Classifier: Programming Language :: Python :: 3.8
199259 Classifier: Topic :: Internet :: WWW/HTTP
200260 Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
201261 Classifier: Topic :: Software Development :: Libraries :: Python Modules
262 Requires-Python: >=3.6
263 Provides-Extra: dev
0 .flake8
10 AUTHORS
21 CODE_OF_CONDUCT.md
32 CONTRIBUTING.rst
76 Makefile
87 README.rst
98 manage_dev.py
10 requirements_dev.txt
11 requirements_test.txt
129 setup.cfg
1310 setup.py
1411 tox.ini
1512 django_ldapdb.egg-info/PKG-INFO
1613 django_ldapdb.egg-info/SOURCES.txt
1714 django_ldapdb.egg-info/dependency_links.txt
15 django_ldapdb.egg-info/not-zip-safe
1816 django_ldapdb.egg-info/requires.txt
1917 django_ldapdb.egg-info/top_level.txt
20 django_ldapdb.egg-info/zip-safe
2118 examples/__init__.py
2219 examples/admin.py
2320 examples/models.py
0 Django>=1.11
0 Django>=2.2
11 python-ldap>=3.0
2
3 [dev]
4 check-manifest
5 flake8
6 isort>=5.0.0
7 tox
8 factory_boy
9 volatildap>=1.1.0
10 wheel
11 zest.releaser[recommended]
+0
-1
django_ldapdb.egg-info/zip-safe less more
0
00 # -*- coding: utf-8 -*-
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
3
4 from __future__ import unicode_literals
53
64 import ldapdb.models
75 from ldapdb.models import fields
1412 # LDAP meta-data
1513 base_dn = "ou=people,dc=example,dc=org"
1614 object_classes = ['posixAccount', 'shadowAccount', 'inetOrgPerson']
17 last_modified = fields.DateTimeField(db_column='modifyTimestamp')
15 last_modified = fields.DateTimeField(db_column='modifyTimestamp', editable=False)
1816
1917 # inetOrgPerson
2018 first_name = fields.CharField(db_column='givenName', verbose_name="Prime name")
00 # -*- coding: utf-8 -*-
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
3
4 from __future__ import unicode_literals
53
64 import ldap
75
9290 'django.template.context_processors.debug',
9391 'django.template.context_processors.i18n',
9492 'django.template.context_processors.media',
93 'django.template.context_processors.request',
9594 'django.template.context_processors.static',
9695 'django.template.context_processors.tz',
9796 'django.contrib.messages.context_processors.messages',
00 # -*- coding: utf-8 -*-
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
3
4 from __future__ import unicode_literals
53
64 import time
75
9997
10098 @classmethod
10199 def setUpClass(cls):
102 super(BaseTestCase, cls).setUpClass()
100 super().setUpClass()
103101 cls.ldap_server = volatildap.LdapServer(
104102 initial_data=cls.directory,
105103 schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'],
111109 @classmethod
112110 def tearDownClass(cls):
113111 cls.ldap_server.stop()
114 super(BaseTestCase, cls).tearDownClass()
112 super().tearDownClass()
115113
116114 def setUp(self):
117 super(BaseTestCase, self).setUp()
115 super().setUp()
118116 self.ldap_server.start()
119117
120118
690688 directory = dict([groups, people, foogroup, contacts])
691689
692690 def setUp(self):
693 super(ScopedTestCase, self).setUp()
691 super().setUp()
694692 self.scoped_model = LdapGroup.scoped("ou=contacts,%s" %
695693 LdapGroup.base_dn)
696694
808806 directory = dict([groups, people, foouser, foogroup, bargroup])
809807
810808 def setUp(self):
811 super(AdminTestCase, self).setUp()
809 super().setUp()
812810 self._user = UserFactory(
813811 username='test_user',
814812 cleartext_password='password',
22 # Copyright (c) The django-ldapdb project
33
44
5 from django.conf.urls import include, url
65 from django.contrib import admin
6 from django.urls import include, path
77
88 admin.autodiscover()
99
1010 urlpatterns = [
11 url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
12 url(r'^admin/', admin.site.urls),
11 path('admin/doc/', include('django.contrib.admindocs.urls')),
12 path('admin/', admin.site.urls),
1313 ]
22 # Copyright (c) The django-ldapdb project
33
44
5 import sys
6
75 import ldap.filter
86 from django.conf import settings
97
8 from .version import __version__ # noqa
9
1010
1111 def escape_ldap_filter(value):
12 if sys.version_info[0] < 3:
13 text_value = unicode(value) # noqa: F821
14 else:
15 text_value = str(value)
16 return ldap.filter.escape_filter_chars(text_value)
12 return ldap.filter.escape_filter_chars(str(value))
1713
1814
1915 # Legacy single database support
2016 if hasattr(settings, 'LDAPDB_SERVER_URI'):
2117 from django import db
18
2219 from ldapdb.router import Router
2320
2421 # Add the LDAP backend
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
33
4 from __future__ import unicode_literals
5
4 import django
65 import ldap
76 import ldap.controls
87 from django.db.backends.base.base import BaseDatabaseWrapper
7271 def no_limit_value(self):
7372 return -1
7473
75 def sql_flush(self, style, tables, sequences, allow_cascade=False):
74 def sql_flush(self, style, tables, *, allow_cascade=False, reset_sequences=False):
7675 return []
76
77 if django.VERSION < (3, 1):
78 # Backwards compatibility
79 def sql_flush(self, style, tables, sequences, allow_cascade=False): # noqa
80 return []
7781
7882
7983 class DatabaseValidation(BaseDatabaseValidation):
214218 }
215219
216220 def __init__(self, *args, **kwargs):
217 super(DatabaseWrapper, self).__init__(*args, **kwargs)
221 super().__init__(*args, **kwargs)
218222
219223 # Charset used for LDAP text *values*
220224 self.charset = "utf-8"
253257 }
254258
255259 def ensure_connection(self):
256 super(DatabaseWrapper, self).ensure_connection()
260 super().ensure_connection()
257261
258262 # Do a test bind, which will revive the connection if interrupted, or reconnect
259263 conn_params = self.get_connection_params()
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
33
4 from __future__ import unicode_literals
5
64 import collections
75 import re
8 import sys
96
107 import ldap
118 from django.db.models import aggregates
1512
1613 from ldapdb import escape_ldap_filter
1714 from ldapdb.models.fields import ListField
18
19 if sys.version_info[0] < 3:
20 integer_types = (int, long) # noqa: F821
21 else:
22 integer_types = (int,)
23
2415
2516 _ORDER_BY_LIMIT_OFFSET_RE = re.compile(
2617 r'(?:\bORDER BY\b\s+(.+?))?\s*(?:\bLIMIT\b\s+(-?\d+))?\s*(?:\bOFFSET\b\s+(\d+))?$')
113104 """Parse a WhereNode to a LDAP filter string."""
114105 if isinstance(node, WhereNode):
115106 return where_node_as_ldap(node, self, self.connection)
116 return super(SQLCompiler, self).compile(node, *args, **kwargs)
107 return super().compile(node, *args, **kwargs)
117108
118109 def execute_sql(self, result_type=compiler.SINGLE, chunked_fetch=False,
119110 chunk_size=GET_ITERATOR_CHUNK_SIZE):
312303 class SQLAggregateCompiler(compiler.SQLAggregateCompiler, SQLCompiler):
313304 def execute_sql(self, result_type=compiler.SINGLE):
314305 # Return only number values through the aggregate compiler
315 output = super(SQLAggregateCompiler, self).execute_sql(result_type)
316 if sys.version_info < (3,):
317 return filter(lambda a: isinstance(a, int), output)
318 return filter(lambda a: isinstance(a, integer_types), output)
306 output = super().execute_sql(result_type)
307 return filter(lambda a: isinstance(a, int), output)
00 # -*- coding: utf-8 -*-
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
3
4 from __future__ import unicode_literals
53
64 import logging
75
2725 object_classes = ['top']
2826
2927 def __init__(self, *args, **kwargs):
30 super(Model, self).__init__(*args, **kwargs)
28 super().__init__(*args, **kwargs)
3129 self._saved_dn = self.dn
3230 if self.dn:
3331 self.base_dn = self.dn.split(',', 1)[1]
00 # -*- coding: utf-8 -*-
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
3
4 from __future__ import unicode_literals
53
64 import datetime
75 import re
145143 def __init__(self, *args, **kwargs):
146144 defaults = {'max_length': 200}
147145 defaults.update(kwargs)
148 super(CharField, self).__init__(*args, **defaults)
146 super().__init__(*args, **defaults)
149147
150148 def from_ldap(self, value, connection):
151149 if len(value) == 0:
183181 return int(value[0])
184182
185183 def get_prep_value(self, value):
186 value = super(IntegerField, self).get_prep_value(value)
184 value = super().get_prep_value(value)
187185 return str(value)
188186
189187
201199 return float(value[0])
202200
203201 def get_prep_value(self, value):
204 value = super(FloatField, self).get_prep_value(value)
202 value = super().get_prep_value(value)
205203 return str(value)
206204
207205
219217 return value[0].upper() == b'TRUE'
220218
221219 def get_prep_value(self, value):
222 value = super(BooleanField, self).get_prep_value(value)
220 value = super().get_prep_value(value)
223221 return 'TRUE' if value else 'FALSE'
224222
225223
266264 self._date_format = kwargs.pop('format')
267265 else:
268266 self._date_format = '%Y-%m-%d'
269 super(DateField, self).__init__(*args, **kwargs)
267 super().__init__(*args, **kwargs)
270268
271269 def from_ldap(self, value, connection):
272270 if len(value) == 0:
276274 self._date_format).date()
277275
278276 def get_prep_value(self, value):
279 value = super(DateField, self).get_prep_value(value)
277 value = super().get_prep_value(value)
280278 if not isinstance(value, datetime.date) \
281279 and not isinstance(value, datetime.datetime):
282280 raise ValueError(
349347 return datetime_from_ldap(value[0].decode(connection.charset))
350348
351349 def get_prep_value(self, value):
352 value = super(DateTimeField, self).get_prep_value(value)
350 value = super().get_prep_value(value)
353351 if not isinstance(value, datetime.date) \
354352 and not isinstance(value, datetime.datetime):
355353 raise ValueError(
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
33
4
5 from __future__ import unicode_literals
64
75 import datetime
86
11 # This software is distributed under the two-clause BSD license.
22 # Copyright (c) The django-ldapdb project
33
4 from __future__ import unicode_literals
4 import sys
55
6 __version__ = '1.4.0'
6 if sys.version_info < (3, 8):
7 import pkg_resources
8
9 __version__ = pkg_resources.get_distribution('django-ldapdb').version
10
11 else:
12 import importlib.metadata
13
14 __version__ = importlib.metadata.version('django-ldapdb')
715
816 VERSION = __version__
+0
-6
requirements_dev.txt less more
0 -e .
1 -r requirements_test.txt
2
3 tox
4 wheel
5 zest.releaser[recommended]
+0
-6
requirements_test.txt less more
0 # Requirements for executing tests
1 check-manifest
2 flake8
3 factory_boy
4 isort
5 volatildap>=1.1.0
0 [metadata]
1 name = django-ldapdb
2 version = 1.5.1
3 description = A LDAP database backend for Django
4 long_description = file: README.rst
5 keywords = django, ldap, database, ldapdb
6 url = https://github.com/django-ldapdb/django-ldapdb
7 author = Jeremy Lainé
8 author_email = jeremy.laine@m4x.org
9 maintainer = Raphaël Barrois
10 maintainer_email = raphael.barrois+django-ldapdb@polytechnique.org
11 license = BSD
12 classifiers =
13 Development Status :: 5 - Production/Stable
14 Environment :: Web Environment
15 Framework :: Django :: 2.2
16 Framework :: Django :: 3.0
17 Framework :: Django :: 3.1
18 Intended Audience :: Developers
19 Intended Audience :: System Administrators
20 License :: OSI Approved :: BSD License
21 Programming Language :: Python
22 Programming Language :: Python :: 3.6
23 Programming Language :: Python :: 3.7
24 Programming Language :: Python :: 3.8
25 Topic :: Internet :: WWW/HTTP
26 Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
27 Topic :: Software Development :: Libraries :: Python Modules
28
29 [options]
30 zip_safe = false
31 packages = find:
32 include_package_data = true
33 python_requires = >=3.6
34 install_requires =
35 Django>=2.2
36 python-ldap>=3.0
37 setup_requires = setuptools
38
39 [options.packages.find]
40 include =
41 ldapdb
42
43 [options.extras_require]
44 dev =
45 check-manifest
46 flake8
47 isort>=5.0.0
48 tox
49 factory_boy
50 volatildap>=1.1.0
51 wheel
52 zest.releaser[recommended]
53
054 [bdist_wheel]
155 universal = true
256
357 [zest.releaser]
458 version-levels = 3
5 python-file-with-version = ldapdb/version.py
659
760 [distutils]
861 index-servers = pypi
62
63 [flake8]
64 max-line-length = 120
65 ignore = W503
966
1067 [egg_info]
1168 tag_build =
22 # This software is distributed under the two-clause BSD license.
33 # Copyright (c) The django-ldapdb project
44
5 from __future__ import unicode_literals
5 from setuptools import setup
66
7 import codecs
8 import os
9 import re
10
11 from setuptools import find_packages, setup
12
13 root_dir = os.path.abspath(os.path.dirname(__file__))
14
15
16 def get_version(package_name):
17 version_re = re.compile(r"^__version__ = [\"']([\w_.-]+)[\"']$")
18 package_components = package_name.split('.')
19 init_path = os.path.join(root_dir, *(package_components + ['version.py']))
20 with codecs.open(init_path, 'r', 'utf-8') as f:
21 for line in f:
22 match = version_re.match(line[:-1])
23 if match:
24 return match.groups()[0]
25 return '0.1.0'
26
27
28 PACKAGE = 'django-ldapdb'
29 PYPACKAGE = 'ldapdb'
30
31
32 setup(
33 name=PACKAGE,
34 version=get_version(PYPACKAGE),
35 description="An LDAP database backend for Django",
36 long_description=''.join(codecs.open('README.rst', 'r', 'utf-8').readlines()),
37 author="Jeremy Laine",
38 author_email="jeremy.laine@m4x.org",
39 maintainer="Raphaël Barrois",
40 maintainer_email="raphael.barrois+%s@polytechnique.org" % PACKAGE,
41 license="BSD",
42 zip_safe=True,
43 keywords=['django', 'ldap', 'database'],
44 url="https://github.com/{pn}/{pn}".format(pn=PACKAGE),
45 packages=find_packages(exclude=['tests*', 'examples*']),
46 install_requires=[
47 'Django>=1.11',
48 'python-ldap>=3.0',
49 ],
50 setup_requires=[
51 'setuptools>=0.8',
52 ],
53 classifiers=[
54 "Development Status :: 5 - Production/Stable",
55 "Environment :: Web Environment",
56 "Programming Language :: Python",
57 "Programming Language :: Python :: 2.7",
58 "Programming Language :: Python :: 3.4",
59 "Programming Language :: Python :: 3.5",
60 "Programming Language :: Python :: 3.6",
61 "Programming Language :: Python :: 3.7",
62 "Framework :: Django :: 1.11",
63 "Framework :: Django :: 2.0",
64 "Framework :: Django :: 2.1",
65 "Intended Audience :: Developers",
66 "Intended Audience :: System Administrators",
67 "License :: OSI Approved :: BSD License",
68 "Topic :: Internet :: WWW/HTTP",
69 "Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP",
70 "Topic :: Software Development :: Libraries :: Python Modules",
71 ],
72 test_suite = 'manage_dev.run_tests',
73 )
7 setup()
00 [tox]
1 envlist = py{27,34,35,36,37}-django111, py{35,36,37}-django21, py{35,36,37}-django22, lint
1 envlist = py{36,37,38}-django{22,30,31}, lint
22
33 [testenv]
4 extras = dev
45 deps =
5 -rrequirements_test.txt
6 django111: Django>=1.11,<1.12
7 django21: Django>=2.1,<2.2
86 django22: Django>=2.2,<2.3
7 django30: Django>=3.0,<3.1
8 django31: Django>=3.1,<3.2
99
1010 whitelist_externals = make
1111 commands = make test
1212
1313 [testenv:lint]
14 deps =
15 -rrequirements_test.txt
14 extras = dev
1615 whitelist_externals = make
1716 commands = make lint