From 7c5b6e2db25f3169d420e643dd249402e2814b91 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 10 Nov 2014 23:15:08 +0100 Subject: [PATCH] improve performance --- tiramisu/config.py | 6 ++++++ tiramisu/option/optiondescription.py | 13 +++++++------ tiramisu/value.py | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index 62f8308..167cd19 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -717,6 +717,12 @@ class GroupConfig(_CommonConfig): pass return self._find_return_results(ret, display_error) + def __repr__(self): + return object.__repr__(self) + + def __str__(self): + return object.__str__(self) + class MetaConfig(GroupConfig): __slots__ = tuple() diff --git a/tiramisu/option/optiondescription.py b/tiramisu/option/optiondescription.py index 0ec8c56..e9898d3 100644 --- a/tiramisu/option/optiondescription.py +++ b/tiramisu/option/optiondescription.py @@ -132,16 +132,17 @@ class OptionDescription(BaseOption, StorageOptionDescription): for option in self._impl_getchildren(dyn=False): #FIXME specifique id for sqlalchemy? #FIXME avec sqlalchemy ca marche le multi parent ? (dans des configs différentes) - #if option.id is None: - # raise SystemError(_("an option's id should not be None " - # "for {0}").format(option.impl_getname())) - if option._get_id() in cache_option: # pragma: optional cover - raise ConflictError(_('duplicate option: {0}').format(option)) - cache_option.append(option._get_id()) + oid = option._get_id() + cache_option.append(oid) option._set_readonly() if isinstance(option, OptionDescription): option.impl_validate_options(cache_option) if init: + if len(cache_option) != len(set(cache_option)): + for idx in xrange(1, len(cache_option)+1): + opt = cache_option.pop(0) + if opt in cache_option: + raise ConflictError(_('duplicate option: {0}').format(opt)) self._set_readonly() # ____________________________________________________________ diff --git a/tiramisu/value.py b/tiramisu/value.py index fb2e36d..775e274 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -102,7 +102,7 @@ class Values(object): #doit passer de meta à pas meta #en plus il faut gérer la longueur avec les meta ! #FIXME SymLinkOption - value = meta.cfgimpl_get_values()[opt] + value = meta.cfgimpl_get_values()._get_cached_item(opt, path) if isinstance(value, Multi): if index is not undefined: value = value[index] @@ -356,8 +356,8 @@ class Values(object): raise ConfigError(_('owner only avalaible for an option')) context = self._getcontext() setting = context.cfgimpl_get_settings() - if 'frozen' in setting[opt] and \ - 'force_default_on_freeze' in setting[opt]: + if 'frozen' in setting._getitem(opt, path) and \ + 'force_default_on_freeze' in setting._getitem(opt, path): return owners.default if validate_properties: self._getitem(opt, path, True, force_permissive, None, True)