From: Zac Medico Date: Tue, 18 Oct 2011 05:26:27 +0000 (-0700) Subject: Fix serialize_eclasses = False in cache template. X-Git-Tag: v2.2.0_alpha69~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=095a648f4726a467934b819e214a2468308ca351;p=portage.git Fix serialize_eclasses = False in cache template. This fixes volatile cache validation that did not get fixed in commit a63c163a50bf8a4e5ca8673cd8bebae29c36643a. Now all volatile cache problems that have been introduced since commit 2ed1cb53cc4158af08c22d466b15b9a9a7767212 should be fixed. --- diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py index a76a5f59f..515ba022b 100644 --- a/pym/portage/cache/template.py +++ b/pym/portage/cache/template.py @@ -64,24 +64,46 @@ class database(object): override this in derived classess""" raise NotImplementedError + @staticmethod + def _internal_eclasses(extern_ec_dict, chf_type, paths): + """ + When serialize_eclasses is False, we have to convert an external + eclass dict containing hashed_path objects into an appropriate + internal dict containing values of chf_type (and eclass dirs + if store_eclass_paths is True). + """ + if not extern_ec_dict: + return extern_ec_dict + chf_getter = operator.attrgetter(chf_type) + if paths: + intern_ec_dict = dict((k, (v.eclass_dir, chf_getter(v))) + for k, v in extern_ec_dict.items()) + else: + intern_ec_dict = dict((k, chf_getter(v)) + for k, v in extern_ec_dict.items()) + return intern_ec_dict + def __setitem__(self, cpv, values): """set a cpv to values This shouldn't be overriden in derived classes since it handles the readonly checks""" if self.readonly: raise cache_errors.ReadOnlyRestriction() + d = None if self.cleanse_keys: d=ProtectedDict(values) for k, v in list(d.items()): if not v: del d[k] - if self.serialize_eclasses and "_eclasses_" in values: + if "_eclasses_" in values: + if d is None: + d = ProtectedDict(values) + if self.serialize_eclasses: d["_eclasses_"] = serialize_eclasses(d["_eclasses_"], self.validation_chf, paths=self.store_eclass_paths) - elif self.serialize_eclasses and "_eclasses_" in values: - d = ProtectedDict(values) - d["_eclasses_"] = serialize_eclasses(d["_eclasses_"], - self.validation_chf, paths=self.store_eclass_paths) - else: + else: + d["_eclasses_"] = self._internal_eclasses(d["_eclasses_"], + self.validation_chf, self.store_eclass_paths) + elif d is None: d = values self._setitem(cpv, d) if not self.autocommits: diff --git a/pym/portage/cache/volatile.py b/pym/portage/cache/volatile.py index a3c57f55f..55167451b 100644 --- a/pym/portage/cache/volatile.py +++ b/pym/portage/cache/volatile.py @@ -17,7 +17,7 @@ class database(template.database): self._data = {} self._delitem = self._data.__delitem__ - def __setitem__(self, name, values): + def _setitem(self, name, values): self._data[name] = copy.deepcopy(values) def __getitem__(self, cpv):