mirror of
https://github.com/jeffknupp/sandman2.git
synced 2026-04-25 00:25:49 +03:00
[GH-ISSUE #40] running multiple sandman2 apps under a single wsgi #25
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
pull-request
question
refactoring
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sandman2-jeffknupp#25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @thatcher on GitHub (Aug 3, 2016).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/40
Hi Jeff. We have many legacy databases we are trying to do some data extraction on. We initially set up our approach using a single db/wsgi.py which does something like:
in
foo/services/goop.pyandfoo/services/blah.pywe havewhere the idea is we can hit paths like:
/foo/-> general stuff for our project/foo/goop/admin/-> sandman2 admin for goop database/foo/blah/admin/-> sandman2 admin for blah databaseThe problem is we see the table for both databases in both admin panels! And we get a lot of errors like:
SAWarning: This declarative base already contains a class with the same class name and module name...The gist appears to be that there can only be one call to sandman2.get_app per wsgi as there is some class level state being set/stored and thus duplicating the information across the admin pages.
Thoughts? Is there just a better way we are missing or does it boil down to a separate wsgi per database?
Thanks!
Thatcher
@jeffknupp commented on GitHub (Aug 3, 2016):
This can be done, but I need to see how much refactoring is necessary. In the meantime, you're free to use a separate wsgi server per database and all will work as expected (though I realize that's not ideal).
@thatcher commented on GitHub (Aug 5, 2016):
Thanks Jeff. Appreciated.
@ptrourke commented on GitHub (Aug 5, 2016):
Jeff, thanks a lot, really appreciate you looking at this! (A colleague of @thatcher )
@Carelvd commented on GitHub (Nov 5, 2019):
The Flask-Admin instance retains some internal state when it is initiated, in some cases when running the unit tests and instantiating Flask-Admin outside of the application factory I have encountered an error claiming I have registered duplicate views. (I had a link somewhere to the Flask-Admin issue tracker that explained this but can't find it now.)
The Flask-SQLAlchemy instance use the "DATABASE_URL" value set upon the application. This is read whenever one invokes it directly
SQLALchemy(app)or initiates an instance,data=SQLAlchemy(), later ondatabase.init(app). My understanding is that flask supports multiple database connections through binds, but I have not used this personally. Perhaps setting this might allow you to map multiple databases in one instance but I think the Flask-Admin issue might still bite you.