On 11/26/2013 09:57 AM, Jan Cholasta wrote:
On 25.11.2013 14:41, Petr Viktorin wrote:
On 11/25/2013 01:05 PM, Jan Cholasta wrote:
On 6.11.2013 13:28, Petr Viktorin wrote:
Hello Honza,
This is a simple enough patch, but I'd like you to check if it's
consistent with your vision of the framework.


I used self._raw here deliberately, so that calling repr() on an
LDAPEntry does not change its internal state.

I agree that using self._raw alone is insufficient, but I'd like to keep
the "no changes" behavior, perhaps using something like this:

     data = dict(self._raw)
     data.update(self._nice)
     return '%s(%r, %r)' % (type(self).__name__, self._dn, data)

That makes sense.
Newly created entries have None values in _nice so I filtered them out
here.


Nitpick: use iteritems() instead of items().

Besides that, ACK.

Thanks! Changed and pused to master: 76c7f24919d30fdd53e4a1cd32880b55c2437ace

--
PetrĀ³
From bcb542e17112428ae754eb1afbbfb9eedb52eec6 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 6 Nov 2013 12:40:02 +0100
Subject: [PATCH] Improve LDAPEntry.__repr__ for freshly created entries

Creating a LDAPEntry from dict does not set the raw entries,
to display everything we need to combine the underlying data.

https://fedorahosted.org/freeipa/ticket/4015
---
 ipapython/ipaldap.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 027bfa979c0d239cb1c042e5b1ddb8f82f0eb2ad..41ae9ec3fbd706972bd4de79bbaea998ac90b8f5 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -719,7 +719,9 @@ def orig_data(self):
         return self._orig
 
     def __repr__(self):
-        return '%s(%r, %r)' % (type(self).__name__, self._dn, self._raw)
+        data = dict(self._raw)
+        data.update((k, v) for k, v in self._nice.iteritems() if v is not None)
+        return '%s(%r, %r)' % (type(self).__name__, self._dn, data)
 
     def copy(self):
         return LDAPEntry(self)
-- 
1.8.3.1

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

Reply via email to