Re: [Freeipa-devel] [PATCHES] 94-96 Remove Entry and Entity classes

2013-02-04 Thread Jan Cholasta

On 1.2.2013 16:34, Rob Crittenden wrote:

Jan Cholasta wrote:

On 22.1.2013 15:32, Jan Cholasta wrote:

Hi,

these patches remove the Entry and Entity classes and move instantiation
of LDAPEntry objects to LDAPConnection.make_entry factory method.

Apply on top of Petr Viktorin's LDAP code refactoring (part 1  2)
patches.

Honza



Slightly changed patch 95 and rebased all the patches on top of current
master and LDAP code refactoring part 1  2.

Honza


I'm curious why you chose to use __slots__ in the LDAPEntry() class. I'm
not too familiar with this directive but I always thought it was memory
management thing, or are you trying to purposely limit the capabilities
of the class (to prevent us rogue programmers from doing bad things)?

rob



It's the first one, I tend to use __slots__ in single-purpose classes 
like LDAPEntry just to save some space.


Honza

--
Jan Cholasta

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCHES] 94-96 Remove Entry and Entity classes

2013-02-01 Thread Rob Crittenden

Jan Cholasta wrote:

On 22.1.2013 15:32, Jan Cholasta wrote:

Hi,

these patches remove the Entry and Entity classes and move instantiation
of LDAPEntry objects to LDAPConnection.make_entry factory method.

Apply on top of Petr Viktorin's LDAP code refactoring (part 1  2)
patches.

Honza



Slightly changed patch 95 and rebased all the patches on top of current
master and LDAP code refactoring part 1  2.

Honza


I'm curious why you chose to use __slots__ in the LDAPEntry() class. I'm 
not too familiar with this directive but I always thought it was memory 
management thing, or are you trying to purposely limit the capabilities 
of the class (to prevent us rogue programmers from doing bad things)?


rob

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCHES] 94-96 Remove Entry and Entity classes

2013-01-31 Thread Jan Cholasta

On 22.1.2013 15:32, Jan Cholasta wrote:

Hi,

these patches remove the Entry and Entity classes and move instantiation
of LDAPEntry objects to LDAPConnection.make_entry factory method.

Apply on top of Petr Viktorin's LDAP code refactoring (part 1  2) patches.

Honza



Slightly changed patch 95 and rebased all the patches on top of current 
master and LDAP code refactoring part 1  2.


Honza

--
Jan Cholasta
From 47cbd2281d20a28715d11209b274cee8f5f0c495 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Tue, 22 Jan 2013 09:28:25 +0100
Subject: [PATCH 1/3] Add make_entry factory method to LDAPConnection.

Replace all occurences of Entry instantiation with calls to make_entry.
---
 ipaserver/install/adtrustinstance.py | 17 -
 ipaserver/install/cainstance.py  |  2 +-
 ipaserver/install/dsinstance.py  |  2 +-
 ipaserver/install/krbinstance.py |  7 +++
 ipaserver/install/ldapupdate.py  |  4 ++--
 ipaserver/install/replication.py | 18 +-
 ipaserver/install/service.py |  4 ++--
 ipaserver/ipaldap.py |  7 +++
 8 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 16f2136..91e40c8 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -22,7 +22,6 @@ import errno
 import ldap
 import tempfile
 import uuid
-from ipaserver import ipaldap
 from ipaserver.install import installutils
 from ipaserver.install import service
 from ipaserver.install.dsinstance import realm_to_serverid
@@ -327,7 +326,7 @@ class ADTRUSTInstance(service.Service):
 try:
 self.admin_conn.getEntry(new_dn, ldap.SCOPE_BASE)
 except errors.NotFound:
-entry = ipaldap.Entry(new_dn)
+entry = self.admin_conn.make_entry(new_dn)
 entry.setValues(objectclass, [nsContainer])
 try:
 name = new_dn[1].attr
@@ -338,7 +337,7 @@ class ADTRUSTInstance(service.Service):
 entry.setValues(cn, name)
 self.admin_conn.addEntry(entry)
 
-entry = ipaldap.Entry(self.smb_dom_dn)
+entry = self.admin_conn.make_entry(self.smb_dom_dn)
 entry.setValues(objectclass, [self.OBJC_DOMAIN, nsContainer])
 entry.setValues(cn, self.domain_name)
 entry.setValues(self.ATTR_FLAT_NAME, self.netbios_name)
@@ -415,7 +414,7 @@ class ADTRUSTInstance(service.Service):
 ('cn', 'etc'), self.suffix)
 try:
 targets = self.admin_conn.getEntry(targets_dn, ldap.SCOPE_BASE)
-current = ipaldap.Entry((targets_dn, targets.toDict()))
+current = self.admin_conn.make_entry(targets_dn, targets.toDict())
 members = current.getValues('memberPrincipal') or []
 if not(self.cifs_principal in members):
 current.setValues(memberPrincipal, members + [self.cifs_principal])
@@ -447,13 +446,13 @@ class ADTRUSTInstance(service.Service):
 # the principal's proper dn as defined in self.cifs_agent
 try:
 entry = self.admin_conn.getEntry(self.smb_dn, ldap.SCOPE_BASE)
-current = ipaldap.Entry((self.smb_dn, entry.toDict()))
+current = self.admin_conn.make_entry(self.smb_dn, entry.toDict())
 members = current.getValues('member') or []
 if not(self.cifs_agent in members):
 current.setValues(member, members + [self.cifs_agent])
 self.admin_conn.updateEntry(self.smb_dn, entry.toDict(), current.toDict())
 except errors.NotFound:
-entry = ipaldap.Entry(self.smb_dn)
+entry = self.admin_conn.make_entry(self.smb_dn)
 entry.setValues(objectclass, [top, GroupOfNames])
 entry.setValues(cn, self.smb_dn['cn'])
 entry.setValues(member, [self.cifs_agent])
@@ -735,9 +734,9 @@ class ADTRUSTInstance(service.Service):
  range.\nAdd local ID range manually and try  \
  again!)
 
-entry = ipaldap.Entry(DN(('cn', ('%s_id_range' % self.realm)),
- api.env.container_ranges,
- self.suffix))
+entry = self.admin_conn.make_entry(DN(('cn', ('%s_id_range' % self.realm)),
+  api.env.container_ranges,
+  self.suffix))
 entry.setValue('objectclass', 'ipaDomainIDRange')
 entry.setValue('cn', ('%s_id_range' % self.realm))
 entry.setValue('ipaBaseID', str(base_id))
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index d29f674..e3122cf 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -395,7 

[Freeipa-devel] [PATCHES] 94-96 Remove Entry and Entity classes

2013-01-22 Thread Jan Cholasta

Hi,

these patches remove the Entry and Entity classes and move instantiation 
of LDAPEntry objects to LDAPConnection.make_entry factory method.


Apply on top of Petr Viktorin's LDAP code refactoring (part 1  2) patches.

Honza

--
Jan Cholasta

From 437ed20f7a1f483f3dd20e4d80731571acddaf06 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Tue, 22 Jan 2013 09:28:25 +0100
Subject: [PATCH 1/3] Add make_entry factory method to LDAPConnection.

Replace all occurences of Entry instantiation with calls to make_entry.
---
 ipaserver/install/adtrustinstance.py | 17 -
 ipaserver/install/cainstance.py  |  2 +-
 ipaserver/install/dsinstance.py  |  2 +-
 ipaserver/install/krbinstance.py |  7 +++
 ipaserver/install/ldapupdate.py  |  4 ++--
 ipaserver/install/replication.py | 18 +-
 ipaserver/install/service.py |  4 ++--
 ipaserver/ipaldap.py |  7 +++
 8 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 16f2136..91e40c8 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -22,7 +22,6 @@ import errno
 import ldap
 import tempfile
 import uuid
-from ipaserver import ipaldap
 from ipaserver.install import installutils
 from ipaserver.install import service
 from ipaserver.install.dsinstance import realm_to_serverid
@@ -327,7 +326,7 @@ class ADTRUSTInstance(service.Service):
 try:
 self.admin_conn.getEntry(new_dn, ldap.SCOPE_BASE)
 except errors.NotFound:
-entry = ipaldap.Entry(new_dn)
+entry = self.admin_conn.make_entry(new_dn)
 entry.setValues(objectclass, [nsContainer])
 try:
 name = new_dn[1].attr
@@ -338,7 +337,7 @@ class ADTRUSTInstance(service.Service):
 entry.setValues(cn, name)
 self.admin_conn.addEntry(entry)
 
-entry = ipaldap.Entry(self.smb_dom_dn)
+entry = self.admin_conn.make_entry(self.smb_dom_dn)
 entry.setValues(objectclass, [self.OBJC_DOMAIN, nsContainer])
 entry.setValues(cn, self.domain_name)
 entry.setValues(self.ATTR_FLAT_NAME, self.netbios_name)
@@ -415,7 +414,7 @@ class ADTRUSTInstance(service.Service):
 ('cn', 'etc'), self.suffix)
 try:
 targets = self.admin_conn.getEntry(targets_dn, ldap.SCOPE_BASE)
-current = ipaldap.Entry((targets_dn, targets.toDict()))
+current = self.admin_conn.make_entry(targets_dn, targets.toDict())
 members = current.getValues('memberPrincipal') or []
 if not(self.cifs_principal in members):
 current.setValues(memberPrincipal, members + [self.cifs_principal])
@@ -447,13 +446,13 @@ class ADTRUSTInstance(service.Service):
 # the principal's proper dn as defined in self.cifs_agent
 try:
 entry = self.admin_conn.getEntry(self.smb_dn, ldap.SCOPE_BASE)
-current = ipaldap.Entry((self.smb_dn, entry.toDict()))
+current = self.admin_conn.make_entry(self.smb_dn, entry.toDict())
 members = current.getValues('member') or []
 if not(self.cifs_agent in members):
 current.setValues(member, members + [self.cifs_agent])
 self.admin_conn.updateEntry(self.smb_dn, entry.toDict(), current.toDict())
 except errors.NotFound:
-entry = ipaldap.Entry(self.smb_dn)
+entry = self.admin_conn.make_entry(self.smb_dn)
 entry.setValues(objectclass, [top, GroupOfNames])
 entry.setValues(cn, self.smb_dn['cn'])
 entry.setValues(member, [self.cifs_agent])
@@ -735,9 +734,9 @@ class ADTRUSTInstance(service.Service):
  range.\nAdd local ID range manually and try  \
  again!)
 
-entry = ipaldap.Entry(DN(('cn', ('%s_id_range' % self.realm)),
- api.env.container_ranges,
- self.suffix))
+entry = self.admin_conn.make_entry(DN(('cn', ('%s_id_range' % self.realm)),
+  api.env.container_ranges,
+  self.suffix))
 entry.setValue('objectclass', 'ipaDomainIDRange')
 entry.setValue('cn', ('%s_id_range' % self.realm))
 entry.setValue('ipaBaseID', str(base_id))
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index 884ff26..dc4edbb 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -393,7 +393,7 @@ class CADSInstance(service.Service):
(ldap.MOD_ADD, nsslapd-secureport, str(DEFAULT_DSPORT+1))]
 conn.modify_s(DN(('cn', 'config')),