(ids)
| 125 | |
| 126 | def make_responder(retriever): |
| 127 | def responder(ids): |
| 128 | entities = [retriever(id_) for id_ in ids] |
| 129 | entities = [entity for entity in entities if entity] |
| 130 | |
| 131 | if get_method() == "DELETE": |
| 132 | if app.config.get("READONLY", True): |
| 133 | return flask.abort(405) |
| 134 | |
| 135 | for entity in entities: |
| 136 | entity.remove(delete=is_delete()) |
| 137 | |
| 138 | return flask.make_response(jsonify({"deleted": True}), 200) |
| 139 | |
| 140 | if get_method() == "PATCH" and patchable: |
| 141 | if app.config.get("READONLY", True): |
| 142 | return flask.abort(405) |
| 143 | |
| 144 | for entity in entities: |
| 145 | entity.update(flask.request.get_json()) |
| 146 | entity.try_sync(True, False) # write, don't move |
| 147 | |
| 148 | if len(entities) == 1: |
| 149 | return flask.jsonify(_rep(entities[0], expand=is_expand())) |
| 150 | if entities: |
| 151 | return app.response_class( |
| 152 | json_generator(entities, root=name), |
| 153 | mimetype="application/json", |
| 154 | ) |
| 155 | |
| 156 | elif get_method() == "GET": |
| 157 | if len(entities) == 1: |
| 158 | return flask.jsonify(_rep(entities[0], expand=is_expand())) |
| 159 | if entities: |
| 160 | return app.response_class( |
| 161 | json_generator(entities, root=name), |
| 162 | mimetype="application/json", |
| 163 | ) |
| 164 | return flask.abort(404) |
| 165 | |
| 166 | return flask.abort(405) |
| 167 | |
| 168 | responder.__name__ = f"get_{name}" |
| 169 |
nothing calls this directly
no test coverage detected