def api_delete_collection(self, req: gws.IWebRequest, p: DeleteCollectionParams) -> gws.Response: cp = self.collection_proto_from_collection_uid(p.collectionUid) if not cp: raise gws.base.web.error.NotFound() cp.delete(p.collectionUid) return gws.Response()
def api_upload_documents(self, req: gws.IWebRequest, p: UploadDocumentsParams) -> gws.Response: cp = self.collection_proto_from_collection_uid(p.collectionUid) if not cp: raise gws.base.web.error.NotFound() cp.upload_documents(p.collectionUid, p.files) return gws.Response()
def _handle_error(req: WebRequest, err: gws.base.web.error.HTTPException) -> WebResponse: # @TODO: image errors site = t.cast(gws.base.web.site.Object, req.site) if req.output_struct_type: return req.struct_response( gws.Response(error=gws.ResponseError( status=err.code, info=gws.get(err, 'description', '')))) if not site.error_page: return req.error_response(err) try: context = {'request': req, 'error': err.code} res = site.error_page.render(gws.TemplateRenderInput(context=context)) return req.content_response( gws.ContentResponse(content=res.content, mime=res.mime, status=err.code)) except: gws.log.exception() return req.error_response(gws.base.web.error.InternalServerError())