mikeckennedy / python-for-entrepreneurs-course-demos

Contains all the "handout" materials for Talk Python's Python for Entrepreneurs course. This includes notes and the final version of the website code.
https://training.talkpython.fm/courses/explore_entrepreneurs/python-for-entrepreneurs-build-and-launch-your-online-business
MIT License
286 stars 141 forks source link

Video 50807 - NameError: name 'static_cache' is not defined #7

Closed stevepiercy closed 7 years ago

stevepiercy commented 7 years ago

When attempting to run the project in the video, an error is reported.

I was pretty careful to make sure I have all the same files and their content to align with what's in the video, but I must have missed a critical piece.

Traceback (most recent call last): File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid_debugtoolbar/toolbar.py", line 215, in toolbar_tween response = _handler(request) File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid_debugtoolbar/panels/performance.py", line 57, in resource_timer_handler result = handler(request) File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/tweens.py", line 62, in excview_tween reraise(*attrs['exc_info']) File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/compat.py", line 148, in reraise raise value File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/tweens.py", line 22, in excview_tween response = handler(request) File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/router.py", line 155, in handle_request view_name File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/view.py", line 612, in _call_view response = view_callable(context, request) File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/viewderivers.py", line 438, in rendered_view result = view(context, request) File "/Users/stevepiercy/projects/entre/env/lib/python3.5/site-packages/pyramid/viewderivers.py", line 123, in _class_requestonly_view response = getattr(inst, attr)() File "/Users/stevepiercy/projects/entre/blue_yellow_app/blue_yellow_app/controllers/home_controller.py", line 11, in index 'build_cache_id': static_cache.build_cache_id NameError: name 'static_cache' is not defined

danshorstein commented 7 years ago

check your import statements on home_controller.py - it should include

import blue_yellow_app.infrastructure.static_cache as static_cache

stevepiercy commented 7 years ago

At this point in the course, I gave up on following along. There were files missing here and there. Eventually I just pulled all the files from the repo for this chapter, stopped typing along, and watched the videos.

This experience could have been better, for example, by breaking this chapter's directory into subdirectories for each video in the chapter. We do something like that for all the official Pyramid tutorials, except we substitute written narrative for videos.

Chapter/Tutorial: https://github.com/Pylons/pyramid/tree/master/docs/quick_tutorial Source code for the Authentication step: https://github.com/Pylons/pyramid/tree/master/docs/quick_tutorial/authentication

mikeckennedy commented 7 years ago

Thanks for the feedback Steve. Sorry you got stuck.

I think the challenge might be you imagine chapter N to be "here's where I start for chapter N". What it is actually meant to be is the final result of that chapter, not the beginning.

I'll go back through and see if there are reasons it won't run. Each chapter should be exactly as it was at the end of that chapter's videos. It ran when I checked it in, so it would maybe be due to a missing github add for a file? We'll see.

mikeckennedy commented 7 years ago

Hi Steve,

I'm happy to look at your code and see what's missing with the static_cache file. But I just cloned this repo into a totally clean environment and ran every chapter without an error. I also tested the cache busting stuff and it seemed to work from what I had in github.

My best guess is that you missed a step. But I can't think where it is right now... Please post a link to a zipped project or something and I'll have a look.

stevepiercy commented 7 years ago

I got that the directory was the end result. We do the same thing with Pyramid tutorial docs: at the end of each step within a chapter, this is what your code should look like. We often tell users to diff their code against the directory to find mistakes.

Instead of a chapter/repo directory level (macro), I wanted to follow along at each video/step level (micro) within the chapter. There were some points where I blinked, missed something, and had to replay the video several times to find my error or omission. And a couple of times, I couldn't find my mistake, so I filed issues in the GitHub tracker.

I ended up just copying all the files over for the whole chapter. That worked, and I'm not disputing this point. But then I became a passive viewer of the video, instead of actively typing along.

Ultimately I suggest a structure like this:

4-applied-web/...name of step where code changes
4-applied-web/Dark navbars and overriding bootstrap
4-applied-web/...
4-applied-web/From theme to Blue/Yellow
4-applied-web/...

Thanks for your consideration.

mikeckennedy commented 7 years ago

Hey Steve,

Sure that makes sense. I could have considered that more realistically had I done it along the way. I already have people asking why there are so many folders and versions. It's a tough balance to strike. But I appreciate the value of following along for sure.

Best, Michael