Skip to content

Commit

Permalink
Avoid deprecated method, support Pyramid 1.10 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Nov 3, 2018
1 parent 37b3337 commit 2548421
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
10 changes: 9 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.4
---

- Made pyramid_ldap3 compatible with Pyramid 1.10
- We require Pyramid >= 1.4 now


0.3.2
-----

Expand All @@ -7,6 +14,7 @@
to login with a different user name like 'foo*' instead of 'foobar'.
Thanks to Patrick Valsecchi for the bug report.


0.3.1
-----

Expand All @@ -16,6 +24,7 @@
group attributes and want them to be properly formatted, you must enable this
feature by setting get_info to 'SCHEMA' or 'ALL' when calling ldap_setup().


0.3
---

Expand All @@ -36,7 +45,6 @@
- The pool lifetime is now configurable



0.2.3
-----

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@

# General substitutions.
project = 'pyramid_ldap3'
copyright = '2012-2017, Agendaless Consulting et al.'
copyright = '2012-2018, Agendaless Consulting et al.'

# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
version = '0.3'
version = '0.4'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
3 changes: 2 additions & 1 deletion pyramid_ldap3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ def ldap_setup(
def get_connector(request):
return Connector(request.registry, manager)

config.set_request_property(get_connector, 'ldap_connector', reify=True)
config.add_request_method(
get_connector, 'ldap_connector', property=True, reify=True)

intr = config.introspectable(
'pyramid_ldap3 setup',
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
README = open(path.join(here, 'README.rst')).read()
CHANGES = open(path.join(here, 'CHANGES.txt')).read()

requires = ['pyramid>=1.3', 'ldap3>=2.0']
requires = ['pyramid>=1.4', 'ldap3>=2.0']

sampleapp_extras = [
'waitress', 'pyramid_debugtoolbar']
Expand All @@ -17,7 +17,7 @@

setup(
name='pyramid_ldap3',
version='0.3.3',
version='0.4',
description='pyramid_ldap3',
long_description=README + '\n\n' + CHANGES,
classifiers=[
Expand All @@ -31,6 +31,7 @@
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
'Topic :: Software Development :: Libraries :: Python Modules',
"Topic :: System :: Systems Administration"
" :: Authentication/Directory :: LDAP",
Expand Down
9 changes: 4 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ class DummyConfig(object):
def __init__(self):
self.registry = Dummy()
self.directives = []
self.prop_reify = self.prop_name = self.prop = None
self.req_method = self.req_method_args = None

# noinspection PyUnusedLocal
def add_directive(self, name, directive):
self.directives.append(name)

def set_request_property(self, prop, name, reify=False):
self.prop_reify = reify
self.prop_name = name
self.prop = prop
def add_request_method(self, method, name, property=False, reify=False):
self.req_method = method
self.req_method_args = name, property, reify

# noinspection PyUnusedLocal
@staticmethod
Expand Down
15 changes: 6 additions & 9 deletions tests/test_ldap_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ def test_it_defaults_ldap_host(self):
from pyramid_ldap3 import Connector
config = DummyConfig()
self._callFUT(config, 'ldap://dummyhost')
self.assertEqual(config.prop_name, 'ldap_connector')
self.assertEqual(config.prop_reify, True)
self.assertEqual(config.req_method_args, ('ldap_connector', True, True))
request = DummyRequest()
connector = config.prop(request)
connector = config.req_method(request)
self.assertEqual(connector.__class__, Connector)
server = connector.manager.server
import ldap3
Expand All @@ -28,10 +27,9 @@ def test_it_defaults_ldaps_host(self):
from pyramid_ldap3 import Connector
config = DummyConfig()
self._callFUT(config, 'ldaps://dummyhost')
self.assertEqual(config.prop_name, 'ldap_connector')
self.assertEqual(config.prop_reify, True)
self.assertEqual(config.req_method_args, ('ldap_connector', True, True))
request = DummyRequest()
connector = config.prop(request)
connector = config.req_method(request)
self.assertEqual(connector.__class__, Connector)
server = connector.manager.server
import ldap3
Expand All @@ -46,10 +44,9 @@ def test_it_defaults_ldap_hosts(self):
config = DummyConfig()
self._callFUT(config, (
'ldap://plainhost', 'ldaps://sslhost', 'ldap://custom:8389'))
self.assertEqual(config.prop_name, 'ldap_connector')
self.assertEqual(config.prop_reify, True)
self.assertEqual(config.req_method_args, ('ldap_connector', True, True))
request = DummyRequest()
connector = config.prop(request)
connector = config.req_method(request)
self.assertEqual(connector.__class__, Connector)
server_pool = connector.manager.server
import ldap3
Expand Down

0 comments on commit 2548421

Please sign in to comment.