Retype (when cloning) Flag parameters to Bool for search commands.

Flag parameters are always autofill by definition, causing unexpected
search results. This patch retypes them to Bool for search commands,
so that users have to/can enter the desired value manually.

Ticket #689
Ticket #701
This commit is contained in:
Pavel Zuna 2011-01-05 10:07:23 -05:00 committed by Adam Young
parent 75078c0bd4
commit 1af89d0daa
2 changed files with 16 additions and 4 deletions

View File

@ -210,9 +210,15 @@ class Search(Method):
for option in self.obj.params_minus(self.args): for option in self.obj.params_minus(self.args):
if 'no_search' in option.flags: if 'no_search' in option.flags:
continue continue
yield option.clone( if isinstance(option, parameters.Flag):
attribute=True, query=True, required=False, autofill=False yield option.clone_retype(
) option.name, parameters.Bool,
attribute=True, query=True, required=False, autofill=False
)
else:
yield option.clone(
attribute=True, query=True, required=False, autofill=False
)
if not self.extra_options_first: if not self.extra_options_first:
for option in super(Search, self).get_options(): for option in super(Search, self).get_options():
yield option yield option

View File

@ -585,9 +585,15 @@ class Param(ReadOnly):
""" """
Return a new `Param` instance similar to this one, but named differently Return a new `Param` instance similar to this one, but named differently
""" """
return self.clone_retype(name, self.__class__, **overrides)
def clone_retype(self, name, klass, **overrides):
"""
Return a new `Param` instance similar to this one, but of a different type
"""
kw = dict(self.__clonekw) kw = dict(self.__clonekw)
kw.update(overrides) kw.update(overrides)
return self.__class__(name, *self.rules, **kw) return klass(name, *self.rules, **kw)
def normalize(self, value): def normalize(self, value):
""" """