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.

--
Petr³

From 17b9b56ecb7964a5f7723c1e7c9de68e95253932 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <[email protected]>
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..8dbc09000b2c8db1de5d0350045bf2d9ae89934b 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.items() 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
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to