def test_action_entity_for_success(self): ''' Test replace... ''' # not much to verify here - just calls backends... workflow.action_entity(self.src_entity, self.action, self.registry) workflow.action_entity(self.link1, self.action, self.registry)
def post(self, key): if len(self.get_arguments('action')) > 0: # action try: entity = self.registry.get_resource(key) action = self.parse_action() workflow.action_entity(entity, action, self.registry) self.render_entity(entity) except AttributeError as attr: raise HTTPError(400, str(attr)) except KeyError as key: raise HTTPError(404, str(key)) else: # update try: old = self.registry.get_resource(key) new = self.parse_entity(def_kind=old.kind) workflow.update_entity(old, new, self.registry) self.render_entity(old) except AttributeError as attr: raise HTTPError(400, str(attr)) except KeyError as key: raise HTTPError(404, str(key))
def post(self, key): if key == '' or key[-1] != '/': key += '/' if len(self.get_arguments('action')) > 0: # action try: action = self.parse_action() entities = workflow.get_entities_under_path(key, self.registry) for entity in entities: workflow.action_entity(entity, action, self.registry) self.response(200, self.registry.get_default_type(), None) except AttributeError as attr: raise HTTPError(400, str(attr)) elif len(self.parse_entities()) == 0: # create resource (&links) try: entity = self.parse_entity() workflow.create_entity(workflow.create_id(entity.kind), entity, self.registry) self.response(201, self.registry.get_default_type(), {'Location': self.request.protocol + '://' + self.request.host + entity.identifier}) except AttributeError as attr: raise HTTPError(400, str(attr)) elif len(self.parse_entities()) > 0: # update try: mixin = self.registry.get_category(key) new_entities = self.parse_entities() old_entities = workflow.get_entities_under_path(key, self.registry) workflow.update_collection(mixin, old_entities, new_entities, self.registry) self.response(200, self.registry.get_default_type(), None) except AttributeError as attr: raise HTTPError(400, str(attr))