Skip to content

Commit

Permalink
fix: finalize_app breaking invenio
Browse files Browse the repository at this point in the history
* the problem is that without existing tables the register_pages will fail. it
  is a edge case only in the beginning.
  • Loading branch information
utnapischtim committed Mar 21, 2024
1 parent e5ebefc commit f8c64fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion invenio_pages/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f8c64fa

Please sign in to comment.