Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Alembic support from alchemy cookiecutter #3307

Merged
merged 26 commits into from
Aug 5, 2018

Conversation

stevepiercy
Copy link
Member

@stevepiercy stevepiercy commented Jun 23, 2018

WIP. Should be backported to 1.9-branch only upon completion.

See #1597 and Pylons/pyramid-cookiecutter-alchemy#7

@stevepiercy
Copy link
Member Author

@mmerickel I took a stab at merging the cookiecutter's default script with the tutorial's script from the models step. When I run it, I get an import error. See stack trace below.

I'm not sure whether the script is correct and I should wait until I fix the views in the next step to get it to run, or the script is wrong. Will pyramid.bootstrap only work when the app is in a runnable state?

$ env/bin/initialize_tutorial_db development.ini
Traceback (most recent call last):
  File "env/bin/initialize_tutorial_db", line 11, in <module>
    load_entry_point('tutorial', 'console_scripts', 'initialize_tutorial_db')()
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/tutorial/scripts/initialize_db.py", line 40, in main
    env = bootstrap(config_uri)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/pyramid/paster.py", line 107, in bootstrap
    app = get_app(config_uri, options=options)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/pyramid/paster.py", line 28, in get_app
    return loader.get_wsgi_app(name, options)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/plaster_pastedeploy/__init__.py", line 131, in get_wsgi_app
    global_conf=defaults)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/tutorial/__init__.py", line 11, in main
    config.scan()
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/pyramid/config/__init__.py", line 1043, in scan
    ignore=ignore)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/env/lib/python3.5/site-packages/venusian/__init__.py", line 230, in scan
    __import__(modname)
  File "/Users/stevepiercy/projects/hack-on-pyramid/tutorial/tutorial/views/default.py", line 6, in <module>
    from ..models import MyModel
ImportError: cannot import name 'MyModel'

from pyramid.paster import bootstrap, setup_logging
from sqlalchemy.exc import OperationalError

from ..models import Page, User
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use from .. import models and use models.Page etc down below

@stevepiercy
Copy link
Member Author

@mmerickel ready for final review.

@mmerickel mmerickel added this to the 1.10 milestone Jul 30, 2018
Copy link
Member

@mmerickel mmerickel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @stevepiercy.

@mmerickel mmerickel merged commit 76c066c into master Aug 5, 2018
@mmerickel mmerickel deleted the alembic-cookiecutter-alchemy branch August 5, 2018 00:06
mmerickel added a commit that referenced this pull request Aug 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants