Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Build a Social Network with Flask Broadcasting Stream Templates

@kennethlove: "with DATABASE.transaction"

in the video you moved the "with DATABASE.transaction" to the models.py. Why did you keep it in the app.py?

please explain.

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

I'm not sure I understand what you're asking about. Can you give me a bit more detail?

Kenneth Love In the Streaming Templates video you moved "with DATABASE.transaction" to the models.py. Why didn't keep it in the app.py?

Sorry for the confusion.

jamal

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Ah. Well since that transaction should happen for creating the models/user(s) every time that work is being done, it makes more sense to put it into function so it'll happen every time.

If we only had it in app.py, we're only protecting that one use of the function.