[Freeipa-devel] [PATCH] Add Encoder base class and method decorators to encode arguments/decode return values. Also - unit tests.
Jason Gerard DeRose
jderose at redhat.com
Mon May 18 21:29:58 UTC 2009
On Thu, 2009-05-14 at 19:49 +0200, Pavel Zuna wrote:
> I was reviewing value encoding/decoding in the new LDAP backend after
> yesterday's e-mail mini-discussion regarding attribute names with Rob. In a lot
> of functions that pass values directly to python-ldap we have to encode
> arguments coming from plugins and decode values coming from python-ldap in
> return. To save some code and possible save future backends from this encoding
> hell, I wrote an Encoder base class and a two function decorators. They're
> supposed to be used like this:
>
> # import important stuff
> from ipalib.encoder import Encoder, encode_args, decode_retval
>
> class ldap2(CrudBackend, Encoder):
>
> # some code
>
> @encode_args(1, 2, 3)
> @decode_retval()
> def find_entries(self, filter, attrs_list=None, base_dn='',
> scope=_ldap.SCOPE_SUBTREE, time_limit=1, size_limit=3000):
> # we don't have to care about encoding/decoding here anymore
> # and it saves at least 10 lines of code in this method, yay!
>
> # some more code
>
> Pavel
ack. I'm sure this will need some tuning as we start using it, but it
looks like a great start and we should get it committed so we can move
forward.
More information about the Freeipa-devel
mailing list