Comments (5)
Found the issue, and a workaround. The problem is that AlchemyDumps.__init__()
checks if app
is None
before calling the app.cli.add_command
, when this should really be done in AlchemyDumps.init_app()
.
The workaround:
from flask_alchemydumps.cli import alchemydumps as ad_cli
...
def create_app(config_class=Config):
...
alchemydumps.init_app(app, db)
app.cli.add_command(ad_cli)
What's weird is that if I compare to, for example Flask-Migrate
(which adds a db
subcommand), I don't see any call whatsoever to app.cli.add_command()
in the code.
from alchemydumps.
Bonjour Clément : ) not sure if you speak French, but your name sounds like French to me!
Many thanks for the heads up. Just checking if I understood: it might make sense to remove this line from our source code, right?
from alchemydumps.
I am French indeed, good guess :)
After more research, I found the reason why it works for Flask-Migrate: this package uses a setup.py
that's setup following the Flask-CLI convention:
entry_points={
'flask.commands': [
'db=flask_migrate.cli:db'
],
}
I looked at the documentation for Poetry, and it's not clear to me that the same thing can be achieved.
Re: removing that line, I think the most generic solution is to move these two to the end of init_app
. This way it'll work both for the 'standard' and Factory Pattern use cases.
from alchemydumps.
I looked at the documentation for Poetry, and it's not clear to me that the same thing can be achieved.
I know they implement entry points via plugins, but the docs anre a biy blunt on the details — that is all we have there:
plugins
Poetry supports arbitrary plugins which work similarly to setuptools entry points. To match the example in the setuptools documentation, you would use the following:
[tool.poetry.plugins] # Optional super table [tool.poetry.plugins."blogtool.parsers"] ".rst" = "some_module:SomeClass"
Re: removing that line, I think the most generic solution is to move these two to the end of
init_app
. This way it'll work both for the 'standard' and Factory Pattern use cases.
Sure. My bad I got it wrong. This looks like a good solution.
Are you comfortable in opening a PR?
Otherwise, I can try to implement something (either via pyproject.toml
or __init__.py
) this weekend.
from alchemydumps.
I can open a PR for sure, but not before at least ten days. And most probably longer... Busy work is busy 😿
from alchemydumps.
Related Issues (20)
- Could not create. python manage.py dumps create HOT 14
- Dumps might fail if tables are empty
- Problems using vsftpd as ftp-server HOT 6
- Tables not directly mapped to a class don't get dumped. HOT 4
- Use of deprecated library import HOT 7
- sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped entity expected - got '<class 'flask_sqlalchemy.Model'>'
- I am willing to take over this package ..... HOT 6
- Licensing Request HOT 1
- Export to different extensions HOT 1
- .ext. Deprecated HOT 1
- Export to S3
- Fix CI
- Can you call the backup within Flask directly ? HOT 4
- Can you add support for Flask 2.x? HOT 3
- Re-add Coveralls
- python3 support
- Multiple models with abstract (not working) HOT 4
- Allow usage with app factory pattern HOT 3
- problem with windows path HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alchemydumps.