def view(pid_fetcher, search_result, code=200, headers=None, links=None, item_links_factory=None): response = current_app.response_class(serializer.serialize_search( pid_fetcher, search_result, links=links, item_links_factory=item_links_factory), mimetype=mimetype) response.status_code = code if headers is not None: response.headers.extend(headers) file_name = '{date}-inventory.csv'.format(date=datetime.now( tz=pytz.timezone('Europe/Zurich')).strftime('%Y%m%d')) if not response.headers.get('Content-Disposition'): response.headers['Content-Disposition'] = \ 'attachment; filename="{file_name}"'.format( file_name=file_name ) if links is not None: add_link_header(response, links) return response
def view(pid_fetcher, search_result, code=200, headers=None, links=None, item_links_factory=None): response = current_app.response_class( serializer.serialize_search(pid_fetcher, search_result, links=links, item_links_factory=item_links_factory), mimetype=mimetype) response.status_code = code if headers is not None: response.headers.extend(headers) tz = None if current_patron: library = extracted_data_from_ref( current_patron.get('library'), data='record' ) tz = library.get_timezone() file_name = '{date}-inventory.csv'.format( date=datetime.now(tz=tz).strftime('%Y%m%d') ) if not response.headers.get('Content-Disposition'): response.headers['Content-Disposition'] = \ 'attachment; filename="{file_name}"'.format( file_name=file_name ) if links is not None: add_link_header(response, links) return response
def view(pid, record, code=200, headers=None, links_factory=None): response = current_app.response_class( serializer.serialize(pid, record, links_factory=links_factory), mimetype=mimetype) response.status_code = code response.cache_control.no_cache = True # etag/last-modified headers removed if headers is not None: response.headers.extend(headers) if links_factory is not None: add_link_header(response, links_factory(pid)) return response
def view(pid, record, code=200, headers=None, links_factory=None): response = current_app.response_class( serializer.serialize(pid, record, links_factory=links_factory), mimetype=mimetype, ) response.status_code = code etag = f"{response.headers.get('Content-Type')}@v{record.revision_id}" response.set_etag(etag) if headers is not None: response.headers.extend(headers) if links_factory is not None: add_link_header(response, links_factory(pid)) return response
def view(pid, record, code=200, headers=None, links_factory=None): response = current_app.response_class( serializer.serialize(pid, record, links_factory=links_factory), mimetype=mimetype) response.status_code = code # TODO: do we have to set an etag? # response.set_etag('xxxxx') response.last_modified = datetime.now() if headers is not None: response.headers.extend(headers) if links_factory is not None: add_link_header(response, links_factory(pid)) return response
def view(pid, record, code=200, headers=None, links_factory=None): response = current_app.response_class(serializer.serialize( pid, record, links_factory=links_factory), mimetype=mimetype) response.status_code = code response.cache_control.no_cache = True response.set_etag(str(record.revision_id)) response.last_modified = record.updated if headers is not None: response.headers.extend(headers) # set the output filename date = record.created.isoformat() filename = f'stats-{date}.csv' if not response.headers.get('Content-Disposition'): response.headers['Content-Disposition'] = \ f'attachment; filename="{filename}"' if links_factory is not None: add_link_header(response, links_factory(pid)) return response