Re: [Freeipa-devel] [PATCH 408-423] ldap: Remove IPASimpleLDAPObject

2015-04-16 Thread Jan Cholasta

Dne 13.4.2015 v 14:57 Petr Viktorin napsal(a):

On 04/13/2015 08:12 AM, Jan Cholasta wrote:

Dne 9.4.2015 v 17:28 Petr Viktorin napsal(a):

On 04/08/2015 03:18 PM, Jan Cholasta wrote:

Hi,

the attached patches remove IPASimpleLDAPObject from ipaldap.

As a result, the one and only IPA LDAP API is the LDAPClient API.


This is definitely an improvement :)

0408: ACK  (woohoo!)
0409: ACK
0410:
I quite like the new __init__ signature, and the context manager
functionality.
Can you add a comment for the `object.__setattr__(self, '_conn', None)`
in _disconnect? It's a real eyesore.


Added.


0411: ACK
0412: Can _force_schema_updates be set already in __init__?


Unfortunately not. ldap2 is now used with different API instances, and
the current API instance is not available in __init__.

I'm working on an additional patch for
https://fedorahosted.org/freeipa/ticket/3090 to pass the API object to
plugins in their __init__ (because why do it somewhere else), which will
fix this.


0413: ACK
0414: ACK
0415: ACK
0416: I think you should show off the `with` statement support here.


Fixed.


0417: ... and here


Fixed.


0418: ACK
0419: ACK
0420: ACK
0421: ACK


Added a comment about ldap2's locking here as well.

Also moved LDAPClient.schema back to its original location to save some
lines in the patch.


0422: ACK, and good riddance


You missed 423 :-)


Ah, that comment was meant for 423 :)



ACK for all


Rebased and pushed to master: b48cfe05e9e6d9fa0d55c9c61f4ac23d8f5ee743

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 408-423] ldap: Remove IPASimpleLDAPObject

2015-04-13 Thread Jan Cholasta

Dne 9.4.2015 v 17:28 Petr Viktorin napsal(a):

On 04/08/2015 03:18 PM, Jan Cholasta wrote:

Hi,

the attached patches remove IPASimpleLDAPObject from ipaldap.

As a result, the one and only IPA LDAP API is the LDAPClient API.


This is definitely an improvement :)

0408: ACK  (woohoo!)
0409: ACK
0410:
I quite like the new __init__ signature, and the context manager
functionality.
Can you add a comment for the `object.__setattr__(self, '_conn', None)`
in _disconnect? It's a real eyesore.


Added.


0411: ACK
0412: Can _force_schema_updates be set already in __init__?


Unfortunately not. ldap2 is now used with different API instances, and 
the current API instance is not available in __init__.


I'm working on an additional patch for 
https://fedorahosted.org/freeipa/ticket/3090 to pass the API object to 
plugins in their __init__ (because why do it somewhere else), which will 
fix this.



0413: ACK
0414: ACK
0415: ACK
0416: I think you should show off the `with` statement support here.


Fixed.


0417: ... and here


Fixed.


0418: ACK
0419: ACK
0420: ACK
0421: ACK


Added a comment about ldap2's locking here as well.

Also moved LDAPClient.schema back to its original location to save some 
lines in the patch.



0422: ACK, and good riddance


You missed 423 :-)

Thanks for the review.

Updated patches attached.

--
Jan Cholasta
From fc74c1b7dfac2d8dfb2cf638dd53852746227c7b Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Thu, 23 Oct 2014 15:44:40 +0200
Subject: [PATCH 01/16] ldap: Drop python-ldap tuple compatibility

---
 ipapython/ipaldap.py | 69 +++-
 1 file changed, 3 insertions(+), 66 deletions(-)

diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index ce07006..5ba2b8b 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -90,12 +90,6 @@ def value_to_utf8(val):
 
 return unicode(val).encode('utf-8')
 
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def raise_deprecation_error():
-raise RuntimeError(
-this API has been deprecated, see http://www.freeipa.org/page/;
-HowTo/Migrate_your_code_to_the_new_LDAP_API)
-
 class _ServerSchema(object):
 '''
 Properties of a schema retrieved from an LDAP server.
@@ -670,13 +664,6 @@ class IPASimpleLDAPObject(object):
 return self.conn.unbind_s()
 
 
-# Make python-ldap tuple style result compatible with Entry and Entity
-# objects by allowing access to the dn (tuple index 0) via the 'dn'
-# attribute name and the attr dict (tuple index 1) via the 'data'
-# attribute name. Thus:
-# r = result[0]
-# r[0] == r.dn
-# r[1] == r.data
 class LDAPEntry(collections.MutableMapping):
 __slots__ = ('_conn', '_dn', '_names', '_nice', '_raw', '_sync',
  '_not_list', '_orig', '_raw_view', '_single_value_view')
@@ -935,10 +922,6 @@ class LDAPEntry(collections.MutableMapping):
 return value
 
 def __getitem__(self, name):
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-if name in (0, 1):
-raise_deprecation_error()
-
 return self._get_nice(name)
 
 def __delitem__(self, name):
@@ -1023,49 +1006,9 @@ class LDAPEntry(collections.MutableMapping):
 
 return modlist
 
-# FIXME: Remove when python-ldap tuple compatibility is dropped
 def __iter__(self):
-raise_deprecation_error()
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def iterkeys(self):
-return self._nice.iterkeys()
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def itervalues(self):
-for name in self.iterkeys():
-yield self[name]
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def iteritems(self):
-for name in self.iterkeys():
-yield (name, self[name])
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def keys(self):
-return list(self.iterkeys())
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def values(self):
-return list(self.itervalues())
+return iter(self._nice)
 
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def items(self):
-return list(self.iteritems())
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def update(self, _obj={}, **kwargs):
-_obj = dict(_obj, **kwargs)
-super(LDAPEntry, self).update(_obj)
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def popitem(self):
-try:
-name = self.iterkeys().next()
-except StopIteration:
-raise KeyError
-
-return name, self.pop(name)
 
 class LDAPEntryView(collections.MutableMapping):
 __slots__ = ('_entry',)
@@ -1577,14 +1520,11 @@ class LDAPClient(object):
 raise errors.LimitsExceeded()
 return entries[0]
 
-def add_entry(self, entry, 

Re: [Freeipa-devel] [PATCH 408-423] ldap: Remove IPASimpleLDAPObject

2015-04-13 Thread Petr Viktorin

On 04/13/2015 08:12 AM, Jan Cholasta wrote:

Dne 9.4.2015 v 17:28 Petr Viktorin napsal(a):

On 04/08/2015 03:18 PM, Jan Cholasta wrote:

Hi,

the attached patches remove IPASimpleLDAPObject from ipaldap.

As a result, the one and only IPA LDAP API is the LDAPClient API.


This is definitely an improvement :)

0408: ACK  (woohoo!)
0409: ACK
0410:
I quite like the new __init__ signature, and the context manager
functionality.
Can you add a comment for the `object.__setattr__(self, '_conn', None)`
in _disconnect? It's a real eyesore.


Added.


0411: ACK
0412: Can _force_schema_updates be set already in __init__?


Unfortunately not. ldap2 is now used with different API instances, and
the current API instance is not available in __init__.

I'm working on an additional patch for
https://fedorahosted.org/freeipa/ticket/3090 to pass the API object to
plugins in their __init__ (because why do it somewhere else), which will
fix this.


0413: ACK
0414: ACK
0415: ACK
0416: I think you should show off the `with` statement support here.


Fixed.


0417: ... and here


Fixed.


0418: ACK
0419: ACK
0420: ACK
0421: ACK


Added a comment about ldap2's locking here as well.

Also moved LDAPClient.schema back to its original location to save some
lines in the patch.


0422: ACK, and good riddance


You missed 423 :-)


Ah, that comment was meant for 423 :)



ACK for all


--
Petr Viktorin

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 408-423] ldap: Remove IPASimpleLDAPObject

2015-04-09 Thread Petr Viktorin

On 04/08/2015 03:18 PM, Jan Cholasta wrote:

Hi,

the attached patches remove IPASimpleLDAPObject from ipaldap.

As a result, the one and only IPA LDAP API is the LDAPClient API.


This is definitely an improvement :)

0408: ACK  (woohoo!)
0409: ACK
0410:
I quite like the new __init__ signature, and the context manager 
functionality.
Can you add a comment for the `object.__setattr__(self, '_conn', None)` 
in _disconnect? It's a real eyesore.

0411: ACK
0412: Can _force_schema_updates be set already in __init__?
0413: ACK
0414: ACK
0415: ACK
0416: I think you should show off the `with` statement support here.
0417: ... and here
0418: ACK
0419: ACK
0420: ACK
0421: ACK
0422: ACK, and good riddance


--
Petr Viktorin

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


[Freeipa-devel] [PATCH 408-423] ldap: Remove IPASimpleLDAPObject

2015-04-08 Thread Jan Cholasta

Hi,

the attached patches remove IPASimpleLDAPObject from ipaldap.

As a result, the one and only IPA LDAP API is the LDAPClient API.

Honza

--
Jan Cholasta
From 89ffd2ed1a058f5d56129dd2b9f62383406898dc Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Thu, 23 Oct 2014 15:44:40 +0200
Subject: [PATCH 01/16] ldap: Drop python-ldap tuple compatibility

---
 ipapython/ipaldap.py | 69 +++-
 1 file changed, 3 insertions(+), 66 deletions(-)

diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index ce07006..5ba2b8b 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -90,12 +90,6 @@ def value_to_utf8(val):
 
 return unicode(val).encode('utf-8')
 
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def raise_deprecation_error():
-raise RuntimeError(
-this API has been deprecated, see http://www.freeipa.org/page/;
-HowTo/Migrate_your_code_to_the_new_LDAP_API)
-
 class _ServerSchema(object):
 '''
 Properties of a schema retrieved from an LDAP server.
@@ -670,13 +664,6 @@ class IPASimpleLDAPObject(object):
 return self.conn.unbind_s()
 
 
-# Make python-ldap tuple style result compatible with Entry and Entity
-# objects by allowing access to the dn (tuple index 0) via the 'dn'
-# attribute name and the attr dict (tuple index 1) via the 'data'
-# attribute name. Thus:
-# r = result[0]
-# r[0] == r.dn
-# r[1] == r.data
 class LDAPEntry(collections.MutableMapping):
 __slots__ = ('_conn', '_dn', '_names', '_nice', '_raw', '_sync',
  '_not_list', '_orig', '_raw_view', '_single_value_view')
@@ -935,10 +922,6 @@ class LDAPEntry(collections.MutableMapping):
 return value
 
 def __getitem__(self, name):
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-if name in (0, 1):
-raise_deprecation_error()
-
 return self._get_nice(name)
 
 def __delitem__(self, name):
@@ -1023,49 +1006,9 @@ class LDAPEntry(collections.MutableMapping):
 
 return modlist
 
-# FIXME: Remove when python-ldap tuple compatibility is dropped
 def __iter__(self):
-raise_deprecation_error()
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def iterkeys(self):
-return self._nice.iterkeys()
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def itervalues(self):
-for name in self.iterkeys():
-yield self[name]
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def iteritems(self):
-for name in self.iterkeys():
-yield (name, self[name])
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def keys(self):
-return list(self.iterkeys())
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def values(self):
-return list(self.itervalues())
+return iter(self._nice)
 
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def items(self):
-return list(self.iteritems())
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def update(self, _obj={}, **kwargs):
-_obj = dict(_obj, **kwargs)
-super(LDAPEntry, self).update(_obj)
-
-# FIXME: Remove when python-ldap tuple compatibility is dropped
-def popitem(self):
-try:
-name = self.iterkeys().next()
-except StopIteration:
-raise KeyError
-
-return name, self.pop(name)
 
 class LDAPEntryView(collections.MutableMapping):
 __slots__ = ('_entry',)
@@ -1577,14 +1520,11 @@ class LDAPClient(object):
 raise errors.LimitsExceeded()
 return entries[0]
 
-def add_entry(self, entry, entry_attrs=None):
+def add_entry(self, entry):
 Create a new entry.
 
 This should be called as add_entry(entry).
 
-if entry_attrs is not None:
-raise_deprecation_error()
-
 # remove all [] values (python-ldap hates 'em)
 attrs = dict((k, v) for k, v in entry.raw.iteritems() if v)
 
@@ -1610,14 +1550,11 @@ class LDAPClient(object):
 self.conn.rename_s(dn, new_rdn, delold=int(del_old))
 time.sleep(.3)  # Give memberOf plugin a chance to work
 
-def update_entry(self, entry, entry_attrs=None):
+def update_entry(self, entry):
 Update entry's attributes.
 
 This should be called as update_entry(entry).
 
-if entry_attrs is not None:
-raise_deprecation_error()
-
 # generate modlist
 modlist = entry.generate_modlist()
 if not modlist:
-- 
2.1.0

From ed8885113bc54c75df8979f4da33b49065320ed4 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Wed, 21 Jan 2015 11:14:19 +
Subject: [PATCH 02/16] ldap: Remove unused IPAdmin methods

---
 ipapython/ipaldap.py | 8 
 1 file changed, 8