예제 #1
0
    def __delitem__(self, cpv):
        """delete a key from the cache.

        This shouldn't be overridden in derived classes since it
        handles the readonly checks.
        """
        if self.readonly:
            raise errors.ReadOnly()
        self._delitem(cpv)
        self._sync_if_needed(True)
예제 #2
0
    def __setitem__(self, cpv, values):
        """set a cpv to values

        This shouldn't be overridden in derived classes since it
        handles the readonly checks.
        """
        if self.readonly:
            raise errors.ReadOnly()
        d = ProtectedDict(values)
        if self.cleanse_keys:
            for k in d.iterkeys():
                if not d[k]:
                    del d[k]
            if "_eclasses_" in values:
                d["_eclasses_"] = self.deconstruct_eclasses(d["_eclasses_"])
        elif "_eclasses_" in values:
            d["_eclasses_"] = self.deconstruct_eclasses(d["_eclasses_"])

        d[self._chf_key] = self._chf_serializer(d.pop('_chf_'))
        self._setitem(cpv, d)
        self._sync_if_needed(True)