

from Ft.Ods import Constants


class DictionaryValueKeyMixin:

    def _4ods_setByKey(self,key,value):
        Constants.g_typeCheck[self._keyType](key,self._keyRepoId)

        if self._values.has_key(key):
            self._dbChanges.append((Constants.DictionaryChanges.CHANGE,key,value))
        else:
            self._dbChanges.append((Constants.DictionaryChanges.ADD,key,value))
        self._values[key] = value

    def _4ods_getByKey(self,key):
        return self._values[key]

    def _4ods_deleteByKey(self,key):
        self._dbChanges.append((Constants.DictionaryChanges.REMOVE,key,None))
        del self._values[key]

    def _4ods_initValueKeys(self):
        pass

    def _4ods_prepareKeyChanges(self):
        pass



    def has_key(self,key):
        return self._values.has_key(key)

    def keys(self):
        return self._values.keys()
