from Ft.Ods import PersistentObject, Collection, Constants



class DictionaryObjectValueMixin:

    def _4ods_unprepareValue(self,value):
        Constants.g_typeCheck[self._subType](value,self._subRepoId)
        return value._4ods_getId()


    def _4ods_prepareValue(self,value):
        return self._db._4ods_getPersistentObjectById(self._subType,value)


    def _4ods_initValueValues(self):
        pass

    def _4ods_prepareValueChanges(self):
        pass

    def values(self):
        return map(lambda x,f=self._4ods_prepareValue:f(x),self._values.values())


    def copy(self,deep=1):
        other = apply(self.__class__,(self._db,None,self._keyType,self._subType,None))
        if deep:
            for v in self.keys():
               other[v] = self[v].copy(deep)
        return other
