better cache
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2014 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2014-2017 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
@ -125,6 +125,13 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
cache_option, force_store_values)
|
||||
#cannot set multi option as OptionDescription requires
|
||||
else:
|
||||
if option.impl_is_master_slaves('master'):
|
||||
if not getattr(option, '_dependencies', None):
|
||||
options = []
|
||||
else:
|
||||
options = list(option._dependencies)
|
||||
options.append(option.impl_get_master_slaves())
|
||||
option._dependencies = tuple(options)
|
||||
option._set_readonly(True)
|
||||
is_multi = option.impl_is_multi()
|
||||
if not isinstance(option, SymLinkOption) and 'force_store_value' in option.impl_getproperties():
|
||||
@ -132,8 +139,8 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
for func, all_cons_opts, params in option._get_consistencies():
|
||||
option._valid_consistencies(all_cons_opts[1:], init=False)
|
||||
if func not in allowed_const_list and is_multi:
|
||||
is_slave = option.impl_is_master_slaves()
|
||||
if not is_slave:
|
||||
is_masterslaves = option.impl_is_master_slaves()
|
||||
if not is_masterslaves:
|
||||
raise ValueError(_('malformed consistency option "{0}" '
|
||||
'must be a master/slaves').format(
|
||||
option.impl_getname()))
|
||||
@ -178,7 +185,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
'must not be a multi for {1}').format(
|
||||
require_opt.impl_getname(), option.impl_getname()))
|
||||
if init:
|
||||
session = config._impl_values._p_.getsession()
|
||||
if len(cache_option) != len(set(cache_option)):
|
||||
for idx in xrange(1, len(cache_option) + 1):
|
||||
opt = cache_option.pop(0)
|
||||
@ -194,7 +200,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
self._cache_consistencies[opt] = tuple(cons)
|
||||
self._cache_force_store_values = force_store_values
|
||||
self._set_readonly(False)
|
||||
del(session)
|
||||
|
||||
|
||||
def impl_build_force_store_values(self, config):
|
||||
@ -408,8 +413,7 @@ class SynDynOptionDescription(object):
|
||||
def _impl_getchildren(self, dyn=True, context=undefined):
|
||||
children = []
|
||||
for child in self._opt._impl_getchildren():
|
||||
children.append(self._opt._impl_get_dynchild(child, self._suffix))
|
||||
return children
|
||||
yield(self._opt._impl_get_dynchild(child, self._suffix))
|
||||
|
||||
def impl_getchildren(self):
|
||||
return self._impl_getchildren()
|
||||
|
Reference in New Issue
Block a user