-
Notifications
You must be signed in to change notification settings - Fork 887
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
Remove request.user from wiki2 #3629
Conversation
I think I'm ok with this change. In my own apps there is always a difference between identity and user and I intend to teach it that way but it's probably it's better to try and simplify things where possible for the tutorial. @bertjwregeer ? |
Is the question, for newbies, whether it is better or not to make the distinction between identity and user? Is the distinction a feature that attracts developers to Pyramid versus other frameworks? I prefer completeness. I might not understand the concept when I first read it, but I have many times come back to Pyramid docs and tutorials when my tiny brain is ready to comprehend the concept. That has a lot of value. Side note, whatever is decided, the other wiki tutorial and Quick Tutorial should be updated as well. |
Since "user" isn't something provided by Pyramid, the distinction is whatever the application says it is. For wiki2, identity and user are one and the same, so I don't think
Agreed, if this goes through those will be next. |
Ah, now it clicks with me. See! I told you I have to read things multiple times. Thanks for the clarification. |
I am okay with this change too for the tutorial. In my case the identity object will always be something that is "user" like, and I will no longer have a I think this is a great change that will help simplify the tutorials. |
So working on the tests, have some questions about best practice. It involves routes/URL dispatch, which I don't work with much. To mock
Here's my current work: ab15b5c |
Looking at warehouse, which is my go-to for practical Pyramid, it looks like they mock |
First of all, what's wrong with Secondly, about the structure of the tests, it's a good question - one that may be good to add a pattern for. I tailored the new pytest fixtures toward functional and integration tests without a lot of consideration for patching the config per-test. As you saw, the I guess my question would be, are you thinking you want to start from scratch and build your own app in the test like you've attempted to do so far with If we'd like to patch the config loaded from the ini then I think the approach I've defined falls apart a bit because it starts from the assumption that it's calling |
Yeah, I get The more I think about it the more I think testing with a blank |
I agree with you that the |
Already, ready for review. I removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code LGTM. After @mmerickel approves, I would like to run through the tutorial to ensure that the narrative docs align with the code (references to line numbers in included code, etc.) before this PR is merged.
Thank you!
docs/tutorials/wiki2/src/authentication/tutorial/templates/layout.jinja2
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not want to emphasize that testing request.identity is None
is a thing people can do. We added request.is_authenticated
and it should be used to avoid generally making assumptions about the meaning of identity being None
. I noted it in a couple spots but you can find the rest.
The other issue is that none of the test fixture changes have been backported to the cookiecutter, which needs to be done before this is merged.
Well the I don't know what the best pattern is for the fixtures, I'm glad you're looking at them. A PR to the cookiecutter would help focus on the fixtures. |
FYI, I started a PR to migrate from travis/appveyor to GHA in the cookiecutter on master. I'll backport it when it is approved. |
I'm not familiar with cookiecutter. I'm looking at https://github.com/Pylons/pyramid-cookiecutter-starter/blob/latest/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.repo_name%7D%7D/base_tests.py, but it doesn't seem to have much in common with the tutorial tests |
You're on the right track... you're looking at the default branch (latest) and the ones you want are in the master branch pending release alongside 2.0. |
For an explanation of branches and versions in pyramid-cookiecutter-starter, see https://github.com/Pylons/pyramid-cookiecutter-starter/tree/master#versions |
Aha, yeah, that looks much more familiar! |
I've added cookiecutter changes over at Pylons/pyramid-cookiecutter-starter#102 |
I don't have an opinion about |
Brought in line with new cookiecutter (and tests pass), so this should be g2g. |
WIP, I need to fix the testing tutorial. Right now it gives an error on setting
identity
, I need to add a dummy security policy to the tutorial. (Useful thing for the tutorial to cover anyways.)But wanted to get the discussion going because I feel like people will have opinions. I can see both sides. In my opinion, the tutorial should be as "pure" Pyramid as possible.
request.user
is a nice convenience that a lot of people will opt for, but I think it's important to emphasizerequest.identity
for new users, as that's the construct the framework uses.Thoughts?