On 15.3.2012 14:20, Petr Viktorin wrote:
On 03/15/2012 12:05 PM, Jan Cholasta wrote:
On 15.3.2012 11:36, Jan Cholasta wrote:
(this is a continuation of


the attached patches fix <https://fedorahosted.org/freeipa/ticket/1847>
and <https://fedorahosted.org/freeipa/ticket/2245>:

[PATCH] Fix the procedure for getting default values of command

The parameters used in default_from of other parameters are now properly
validated before the default_from is called.

[PATCH] Change parameters to use only default_from for dynamic default

Replace all occurences of create_default with equivalent default_from
and remove create_default from the framework. This is needed for proper
parameter validation, as there is no way to tell which parameters to
validate prior to calling create_default, because create_default does
not provide information about which parameters are used for generating
the default value.


Forgot to remove one FIXME bit in dns.py. Update patch attached.


 > diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
 > index a10960a..61c645d 100644
 > --- a/ipalib/plugins/dns.py
 > +++ b/ipalib/plugins/dns.py
 > @@ -1528,7 +1528,7 @@ class dnszone(LDAPObject):
 > label=_('SOA serial'),
 > doc=_('SOA record serial number'),
 > minvalue=1,
 > - create_default=_create_zone_serial,
 > + default_from=_create_zone_serial,
 > autofill=True,
 > ),
 > Int('idnssoarefresh',
 > diff --git a/ipalib/plugins/passwd.py b/ipalib/plugins/passwd.py
 > index b26f7e9..9bee314 100644
 > --- a/ipalib/plugins/passwd.py
 > +++ b/ipalib/plugins/passwd.py
 > @@ -69,7 +69,7 @@ class passwd(Command):
 > label=_('User name'),
 > primary_key=True,
 > autofill=True,
 > - create_default=lambda **kw: util.get_current_principal(),
 > + default_from=lambda: util.get_current_principal(),
 > normalizer=lambda value: normalize_principal(value),
 > ),
 > Password('password',

This is just a minor nitpick, but I'd like to know if there's a reason
behind it: why are you sometimes using lambda and sometimes not?

I use lambda as a protective measure against accidents caused by adding optional arguments to the functions used. _create_zone_serial is an exception to that rule, because it is private to the dns plugin.

The patch works well here, but I think I'm not the one to ack it.


Jan Cholasta

Freeipa-devel mailing list

Reply via email to