From f8c64fa660d64b4aa197a20dcde8e13e4a678fdd Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Thu, 21 Mar 2024 15:39:09 +0100 Subject: [PATCH] fix: finalize_app breaking invenio * the problem is that without existing tables the register_pages will fail. it is a edge case only in the beginning. --- invenio_pages/ext.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/invenio_pages/ext.py b/invenio_pages/ext.py index f961af6..6e78716 100644 --- a/invenio_pages/ext.py +++ b/invenio_pages/ext.py @@ -2,14 +2,16 @@ # # This file is part of Invenio. # Copyright (C) 2015-2022 CERN. -# Copyright (C) 2023 Graz University of Technology. +# Copyright (C) 2023-2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Static pages module for Invenio.""" +import sqlalchemy from flask import request, url_for +from invenio_db import db from jinja2.sandbox import SandboxedEnvironment from werkzeug.exceptions import NotFound @@ -128,6 +130,9 @@ def register_pages(app): # in the Flask.url_map app.view_functions["invenio_pages.view"] = view + if not sqlalchemy.inspect(db.engine).has_table("pages_page"): + return + for page in Page.query.all(): if not page.has_custom_view: # Skip registration of pages with custom view add_url_rule(page.url)