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

Days 37-40: Intro to Pyramid: Adding the data models #33

Closed
gloc-mike opened this issue Feb 24, 2020 · 5 comments
Closed

Days 37-40: Intro to Pyramid: Adding the data models #33

gloc-mike opened this issue Feb 24, 2020 · 5 comments

Comments

@gloc-mike
Copy link
Contributor

In this section of the course, I copied the bin, data and db code from the 100 Days GitHub repo into my version of the code.

I found that in data/db_session.py, the return value needs to be the attribute factory i.e. DbSession.factory, rather than the method i.e. DbSession.factory().

However, after fixing that issue, I am now confronted with another. In bin/load_base_data.py, the session returned does not have the 'query' attribute!

I created this Gist which shows the error:
https://gist.github.com/gloc-mike/ddb4fb4ca0aa1ba81209623a8858d606.

When I review the session object in the debug console in PyCharm, I can see that 'query' appears in the public_methods tuple (see attached screenshot) but the my watch expression again, shows the attribute error.

Screen Shot 2020-02-24 at 12 51 24

Any ideas to help me resolve this issue would be appreciated.

@gloc-mike
Copy link
Contributor Author

My assumption is wrong i.e. that DbSession.factory()needed to be refactored to DbSession.factory. so I'm closing this issue.

My code works after reverting to DbSession.factory() but it is still very odd that it did not run when I first copied the data modelling modules into my project. Is there maybe a first run issue?

I'm still at a loss as to why my version was not working. When I was debugging it I could clearly see that the DbSession.factory attribute was set to None which is why it was originally failing but why should it suddenly start working after I revert my change above?

Anyway, I am closing this issue.

@mikeckennedy
Copy link
Member

Hi @gloc-mike It definitely needs to be returning a Session. But I think the problem was it's returning session_maker not session_maker(). One is the function that makes sessions, the other is a particular session created by that function for the Unit of Work.

Hope that helps!
Michael

@gloc-mike
Copy link
Contributor Author

gloc-mike commented Feb 26, 2020

Hi,

I created a new Pyramid project with which I want to build to track timesheet info and I am getting the original error (the error that occurred BEFORE the error I originally reported in this issue).

Please see the Gist I created for this error:
https://gist.github.com/gloc-mike/fd84826f0c505be1e61f7f7493925bd0

I created the timesheet project using PyCharm using the Pyramid project template (not the from the commandline using the cookiecutter template). The PyCharm template for Pyramid comes with a lot of jinja2 code (even though I specified chameleon as the template language) so I removed the jinja2 code, then I added the bits and pieces from the course i.e. the bin, data and db folders and code, and I modified the data model etc. to suite the this project.

After making all of the necessary changes needed, I ran it and it failed when the DbSession.factory() call returned a 'None' value. This error also occurred when I built the bill_tracker version of the project.

Here is the link to the timesheets project on GitHub:
https://github.com/gloc-mike/timesheets

Thanks for the help!
Michael

@gloc-mike gloc-mike reopened this Feb 26, 2020
@mikeckennedy
Copy link
Member

Hi, I responded to the issue in the gist.

@mikeckennedy
Copy link
Member

Hi @gloc-mike There were quite a few issues with the repo. Here's a running version. Try doing a diff on the directories to see what changed. :)

https://send.firefox.com/download/406ddab5c4cabb0c/#iau8zBEX6mH9Bwbd5QOnxQ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants