Skip to content

Commit 54c24f2

Browse files
authored
Merge pull request #1 from python-ldap/master
merge
2 parents 8a752f9 + 7fb02c0 commit 54c24f2

File tree

12 files changed

+328
-113
lines changed

12 files changed

+328
-113
lines changed

Doc/bytes_mode.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ to be given as well.
9393
Porting recommendations
9494
-----------------------
9595

96-
Since end of life of Python 2 is coming in a few years,
97-
projects are strongly urged to make their code compatible with Python 3.
98-
General instructions for this are provided `in Python documentation`_ and in
99-
the `Conservative porting guide`_.
96+
Since end of life of Python 2 is coming in a few years, projects are strongly
97+
urged to make their code compatible with Python 3. General instructions for
98+
this are provided :ref:`in Python documentation <pyporting-howto>` and in the
99+
`Conservative porting guide`_.
100100

101-
.. _in Python documentation: https://docs.python.org/3/howto/pyporting.html
102101
.. _Conservative porting guide: https://portingguide.readthedocs.io/en/latest/
103102

104103

Doc/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131

3232
# Add any Sphinx extension module names here, as strings. They can be extensions
3333
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
34-
extensions = ['sphinx.ext.autodoc']
34+
extensions = [
35+
'sphinx.ext.autodoc',
36+
'sphinx.ext.intersphinx',
37+
]
3538

3639
try:
3740
import sphinxcontrib.spelling
@@ -148,3 +151,5 @@
148151

149152
# If false, no module index is generated.
150153
latex_use_modindex = True
154+
155+
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}

Doc/installing.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ From a source repository::
9999
If you have more than one Python interpreter installed locally, you should
100100
use the same one you plan to use python-ldap with.
101101

102-
Further instructions can be found in `Setuptools documentation`_.
103-
104-
105-
.. _Setuptools documentation: https://docs.python.org/3/distributing/index.html
102+
Further instructions can be found in :ref:`Setuptools documentation
103+
<distributing-index>`.
106104

107105

108106
.. _build prerequisites:
@@ -169,11 +167,10 @@ Packages for building and testing::
169167
setup.cfg
170168
=========
171169

172-
The file setup.cfg allows to set some build and installation
173-
parameters for reflecting the local installation of required
174-
software packages. Only section ``[_ldap]`` is described here.
175-
More information about other sections can be found in
176-
`Setuptools documentation`_.
170+
The file setup.cfg allows to set some build and installation parameters for
171+
reflecting the local installation of required software packages. Only section
172+
``[_ldap]`` is described here. More information about other sections can be
173+
found in :ref:`Setuptools documentation <distributing-index>`.
177174

178175
.. data:: library_dirs
179176

Doc/reference/ldap.rst

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ This module defines the following functions:
6363
:py:const:`2` for logging the method calls with arguments and the complete results and
6464
:py:const:`9` for also logging the traceback of method calls.
6565

66+
Additional keyword arguments are passed to :class:`LDAPObject`.
67+
6668
.. seealso::
6769

6870
:rfc:`4516` - Lightweight Directory Access Protocol (LDAP): Uniform Resource Locator
@@ -579,33 +581,16 @@ LDAPObject classes
579581

580582
.. py:class:: LDAPObject
581583
582-
Instances of :py:class:`LDAPObject` are returned by :py:func:`initialize()`
583-
and :py:func:`open()` (deprecated). The connection is automatically unbound
584+
Instances of :py:class:`LDAPObject` are returned by :py:func:`initialize()`.
585+
The connection is automatically unbound
584586
and closed when the LDAP object is deleted.
585587

586-
Internally :py:class:`LDAPObject` is set to :py:class:`SimpleLDAPObject`
587-
by default.
588-
589-
.. py:class:: SimpleLDAPObject(uri [, trace_level=0 [, trace_file=sys.stdout [, trace_stack_limit=5]]])
590-
591-
This basic class wraps all methods of the underlying C API object.
592-
593-
The arguments are same like for function :py:func:`initialize()`.
594-
595-
.. py:class:: ReconnectLDAPObject(uri [, trace_level=0 [, trace_file=sys.stdout [, trace_stack_limit=5] [, retry_max=1 [, retry_delay=60.0]]]])
596-
597-
This class is derived from :py:class:`SimpleLDAPObject` and used for automatic
598-
reconnects when using the synchronous request methods (see below). This class
599-
also implements the pickle protocol.
600-
601-
The first arguments are same like for function :py:func:`initialize()`.
602-
603-
For automatic reconnects it has additional arguments:
588+
Internally :py:class:`LDAPObject` is set to
589+
:py:class:`~ldap.ldapobject.SimpleLDAPObject` by default.
604590

605-
*retry_max* specifies the number of reconnect attempts before
606-
re-raising the :py:exc:`ldap.SERVER_DOWN` exception.
591+
.. autoclass:: ldap.ldapobject.SimpleLDAPObject
607592

608-
*retry_delay* specifies the time in seconds between reconnect attempts.
593+
.. autoclass:: ldap.ldapobject.ReconnectLDAPObject
609594

610595

611596
.. _ldap-controls:

Doc/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pyasn1
2+
pyasn1_modules

Doc/sample_workflow.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ Clone the repository::
2626
$ git clone https://github.com/python-ldap/python-ldap
2727
$ cd python-ldap
2828

29-
Create a `virtual environment`_ to ensure you in-development python-ldap won't
30-
affect the rest of your system::
29+
Create a :mod:`virtual environment <venv>` to ensure you in-development
30+
python-ldap won't affect the rest of your system::
3131

3232
$ python3 -m venv __venv__
3333

3434
(For Python 2, install `virtualenv`_ and use it instead of ``python3 -m venv``.)
3535

3636
.. _git: https://git-scm.com/
37-
.. _virtual environment: https://docs.python.org/3/library/venv.html
3837
.. _virtualenv: https://virtualenv.pypa.io/en/stable/
3938

4039
Activate the virtual environment::

Lib/ldap/controls/sss.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
]
1313

1414

15+
import sys
16+
1517
import ldap
1618
from ldap.ldapobject import LDAPObject
1719
from ldap.controls import (RequestControl, ResponseControl,
@@ -20,6 +22,10 @@
2022
from pyasn1.type import univ, namedtype, tag, namedval, constraint
2123
from pyasn1.codec.ber import encoder, decoder
2224

25+
PY2 = sys.version_info[0] <= 2
26+
if not PY2:
27+
basestring = str
28+
2329

2430
# SortKeyList ::= SEQUENCE OF SEQUENCE {
2531
# attributeType AttributeDescription,

Lib/ldap/functions.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ def _ldap_function_call(lock,func,*args,**kwargs):
6565
return result
6666

6767

68-
def initialize(uri,trace_level=0,trace_file=sys.stdout,trace_stack_limit=None, bytes_mode=None):
68+
def initialize(
69+
uri, trace_level=0, trace_file=sys.stdout, trace_stack_limit=None,
70+
bytes_mode=None, **kwargs
71+
):
6972
"""
7073
Return LDAPObject instance by opening LDAP connection to
7174
LDAP host specified by LDAP URL
@@ -81,8 +84,12 @@ def initialize(uri,trace_level=0,trace_file=sys.stdout,trace_stack_limit=None, b
8184
Default is to use stdout.
8285
bytes_mode
8386
Whether to enable :ref:`bytes_mode` for backwards compatibility under Py2.
87+
88+
Additional keyword arguments (such as ``bytes_strictness``) are
89+
passed to ``LDAPObject``.
8490
"""
85-
return LDAPObject(uri,trace_level,trace_file,trace_stack_limit,bytes_mode)
91+
return LDAPObject(
92+
uri, trace_level, trace_file, trace_stack_limit, bytes_mode, **kwargs)
8693

8794

8895
def get_option(option):

Lib/ldap/ldapobject.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class NO_UNIQUE_ENTRY(ldap.NO_SUCH_OBJECT):
7676

7777
class SimpleLDAPObject:
7878
"""
79-
Drop-in wrapper class around _ldap.LDAPObject
79+
This basic class wraps all methods of the underlying C API object.
80+
81+
The arguments are same as for the :func:`~ldap.initialize()` function.
8082
"""
8183

8284
CLASSATTR_OPTION_MAPPING = {
@@ -1057,15 +1059,20 @@ def get_naming_contexts(self):
10571059

10581060
class ReconnectLDAPObject(SimpleLDAPObject):
10591061
"""
1060-
In case of server failure (ldap.SERVER_DOWN) the implementations
1061-
of all synchronous operation methods (search_s() etc.) are doing
1062-
an automatic reconnect and rebind and will retry the very same
1063-
operation.
1064-
1065-
This is very handy for broken LDAP server implementations
1066-
(e.g. in Lotus Domino) which drop connections very often making
1067-
it impossible to have a long-lasting control flow in the
1068-
application.
1062+
:py:class:`SimpleLDAPObject` subclass whose synchronous request methods
1063+
automatically reconnect and re-try in case of server failure
1064+
(:exc:`ldap.SERVER_DOWN`).
1065+
1066+
The first arguments are same as for the :py:func:`~ldap.initialize()`
1067+
function.
1068+
For automatic reconnects it has additional arguments:
1069+
1070+
* retry_max: specifies the number of reconnect attempts before
1071+
re-raising the :py:exc:`ldap.SERVER_DOWN` exception.
1072+
1073+
* retry_delay: specifies the time in seconds between reconnect attempts.
1074+
1075+
This class also implements the pickle protocol.
10691076
"""
10701077

10711078
__transient_attrs__ = {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy