Skip to content

[BUG] PAGE_REGISTRY is global, making it impossible to have multiple dash apps with use_pages #2398

Description

@C0DK

Describe your context

dash                      2.7.1
dash-bootstrap-components 1.3.0
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0

Describe the bug
We are trying to create a flask application with multiple dash apps and utilizing use_pages. This creates a problem, however, as the PAGE_REGISTRY is a global variable:

https://github.com/plotly/dash/blob/dev/dash/_pages.py

This means that when we register multiple apps, all the apps will contain all the pages from all apps. I.e I have an app A (at URL /a/) with pages:

  • Page 1
  • Page 2

And an App B (at URL /b/) that contains:

  • Page 6
  • Page 7

Then the following routes will be registered(8 rather than the 4 actually registered):

  • /a/1/
  • /a/2/
  • /a/6/
  • /a/7/
  • /b/1/
  • /b/2/
  • /b/6/
  • /b/7/

This is not ideal.

(And ideally one probably shouldn't use global variables in your code 😛 )

Expected behavior

I expected the routes/pages to be contained within the specific dash app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions