def test_serialize_ActionDescription_DEFAULT(self): obj = ActionDescription('archiving') obj.icon = 'places/folder-remote' obj.label = 'edit the content' res = Context(CTX.DEFAULT).toDict(obj) eq_(res.__class__, DictLikeClass) eq_(obj.id, res.id) eq_(obj.label, res.label) eq_(obj.icon, res.icon) eq_(3, len(res.keys()))
def save(self, content: Content, action_description: str = None, do_flush=True, do_notify=True): """ Save an object, flush the session and set the revision_type property :param content: :param action_description: :return: """ assert action_description is None or action_description in ActionDescription.allowed_values( ) if not action_description: # See if the last action has been modified if content.revision_type == None or len( get_history(content.revision, 'revision_type')) <= 0: # The action has not been modified, so we set it to default edition action_description = ActionDescription.EDITION if action_description: content.revision_type = action_description if do_flush: # INFO - 2015-09-03 - D.A. # There are 2 flush because of the use # of triggers for content creation # # (when creating a content, actually this is an insert of a new # revision in content_revisions ; so the mark_read operation need # to get full real data from database before to be prepared. DBSession.add(content) DBSession.flush() # TODO - 2015-09-03 - D.A. - Do not use triggers # We should create a new ContentRevisionRO object instead of Content # This would help managing view/not viewed status self.mark_read(content, do_flush=True) if do_notify: self.do_notify(content)
def save(self, content: Content, action_description: str=None, do_flush=True, do_notify=True): """ Save an object, flush the session and set the revision_type property :param content: :param action_description: :return: """ assert action_description is None or action_description in ActionDescription.allowed_values() if not action_description: # See if the last action has been modified if content.revision_type==None or len(get_history(content.revision, 'revision_type'))<=0: # The action has not been modified, so we set it to default edition action_description = ActionDescription.EDITION if action_description: content.revision_type = action_description if do_flush: # INFO - 2015-09-03 - D.A. # There are 2 flush because of the use # of triggers for content creation # # (when creating a content, actually this is an insert of a new # revision in content_revisions ; so the mark_read operation need # to get full real data from database before to be prepared. DBSession.add(content) DBSession.flush() # TODO - 2015-09-03 - D.A. - Do not use triggers # We should create a new ContentRevisionRO object instead of Content # This would help managing view/not viewed status self.mark_read(content, do_flush=True) if do_notify: self.do_notify(content)