def _store(self, id=None, code=None, description=None, content=None, common=None, state=None, meta=None, profile_ids=None, is_enabled=None, hidden=None, action=None, kind=None, parts=None, session=None): if action == 'update': dictionary_model = self.dictionary.get(id, session=session) if not dictionary_model: raise ApiError(code="NOT_EXISTS", message="Can't find dictionary with id=%r" % id) else: dictionary_model = Dictionary( created=datetime.now(), version=0, ) if code is not None: dictionary_model.code = code if description is not None: dictionary_model.description = description if content is not None: dictionary_model.content = content if common is not None: dictionary_model.common = common if kind is not None: dictionary_model.kind = kind if state is not None: dictionary_model.state = state if meta is not None: dictionary_model.meta = meta if profile_ids is not None: dictionary_model.profile_ids = profile_ids if is_enabled is not None: dictionary_model.is_enabled = is_enabled if hidden is not None: dictionary_model.hidden = hidden if parts is not None: dictionary_model.parts = parts dictionary_model.version += 1 session.add(dictionary_model) session.flush() data = dictionary_model.to_dict() return data