Skip to content

Instantly share code, notes, and snippets.

@gloc-mike
Created February 26, 2020 04:53
Show Gist options
  • Save gloc-mike/fd84826f0c505be1e61f7f7493925bd0 to your computer and use it in GitHub Desktop.
Save gloc-mike/fd84826f0c505be1e61f7f7493925bd0 to your computer and use it in GitHub Desktop.
DbSession.factory returns 'None' value
/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/bin/python "/Users/michael/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/193.6494.30/PyCharm.app/Contents/plugins/python/helpers/pycharm/pycharm_load_entry_point.py" /Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/development.ini
Connecting to DB at: sqlite:////Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/timesheets/db/timesheets.sqlite
Loading starter data...
Traceback (most recent call last):
File "/Users/michael/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/193.6494.30/PyCharm.app/Contents/plugins/python/helpers/pycharm/pycharm_load_entry_point.py", line 12, in <module>
sys.exit(f())
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/pyramid/scripts/pserve.py", line 34, in main
return command.run()
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/pyramid/scripts/pserve.py", line 275, in run
app = loader.get_wsgi_app(app_name, config_vars)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/plaster_pastedeploy/__init__.py", line 129, in get_wsgi_app
global_conf=defaults,
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/loadwsgi.py", line 253, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/loadwsgi.py", line 278, in loadobj
return context.create()
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/loadwsgi.py", line 715, in create
return self.object_type.invoke(self)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/loadwsgi.py", line 152, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/util.py", line 58, in fix_call
reraise(*exc_info)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/compat.py", line 32, in reraise
raise e.with_traceback(tb)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/venv/lib/python3.7/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/timesheets/__init__.py", line 18, in main
init_db()
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/timesheets/__init__.py", line 30, in init_db
load_base_data.load_starter_data()
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/timesheets/bin/load_base_data.py", line 16, in load_starter_data
session = DbSession.create_session()
File "/Users/michael/Developer/TalkPython/100-days-of-web/100-days-of-web-with-python/037-pyramid/timesheets/timesheets/data/db_session.py", line 39, in create_session
return DbSession.factory()
TypeError: 'NoneType' object is not callable
Process finished with exit code 1
@gloc-mike
Copy link
Author

Thanks Michael!

What's the best way to diff two folders? Use diff from the Terminal?

Thanks
Michael

@mikeckennedy
Copy link

mikeckennedy commented Feb 26, 2020 via email

@gloc-mike
Copy link
Author

Oh sure, of course, thanks. And yes, I'm using PyCharm.

@gloc-mike
Copy link
Author

Thanks Michael!

The main issue is the paths in the __init__.py file, right?

I notice that you used "billtracker.bin", etc., in the bill tracker project (presumably absolute) but you have provided me with the relative(?) path ".bin" etc., in the timesheet project. Are there any advantages of using one over the other?

How did you find them so quicky though?

Also, thanks for fixing the other issues!

@mikeckennedy
Copy link

Hi @gloc-mike

How did I fix it quickly? I just started trying to run it, hit the first problem, tried a few things until it was fixed, then ran again until it hit the next issue, repeat. :) Some were not obvious. I think I might have put default=datetime.datetime.now() rather than default=datetime.datetime.now so be aware you need an update there. :)

As for paths, absolute paths are better if you can manage them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment