Skip to content

Commit

Permalink
update authorization chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Feb 4, 2024
1 parent 286a7a3 commit 3c61799
Show file tree
Hide file tree
Showing 21 changed files with 274 additions and 186 deletions.
16 changes: 8 additions & 8 deletions docs/tutorials/wiki2/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Open the file ``tutorial/routes.py`` and edit the following lines:

.. literalinclude:: src/authorization/tutorial/routes.py
:linenos:
:emphasize-lines: 1-11,18-
:emphasize-lines: 1-11,19-
:language: python

The highlighted lines need to be edited or added.
Expand All @@ -101,7 +101,7 @@ the principals of either ``role:editor`` or ``role:basic`` to have the
``create`` permission:

.. literalinclude:: src/authorization/tutorial/routes.py
:lines: 31-39
:lines: 35-43
:lineno-match:
:emphasize-lines: 5-9
:language: python
Expand All @@ -110,7 +110,7 @@ The ``NewPage`` is loaded as the :term:`context` of the ``add_page`` route by
declaring a ``factory`` on the route:

.. literalinclude:: src/authorization/tutorial/routes.py
:lines: 19-20
:lines: 20-21
:lineno-match:
:emphasize-lines: 1-2
:language: python
Expand All @@ -119,7 +119,7 @@ The ``PageResource`` class defines the :term:`ACL` for a ``Page``. It uses an
actual ``Page`` object to determine *who* can do *what* to the page.

.. literalinclude:: src/authorization/tutorial/routes.py
:lines: 48-
:lines: 54-
:lineno-match:
:emphasize-lines: 5-10
:language: python
Expand All @@ -128,7 +128,7 @@ The ``PageResource`` is loaded as the :term:`context` of the ``view_page`` and
``edit_page`` routes by declaring a ``factory`` on the routes:

.. literalinclude:: src/authorization/tutorial/routes.py
:lines: 18-22
:lines: 19-23
:lineno-match:
:emphasize-lines: 1,4-5
:language: python
Expand Down Expand Up @@ -157,7 +157,7 @@ Edit the ``view_page`` view to declare the ``view`` permission, and remove the
explicit checks within the view:

.. literalinclude:: src/authorization/tutorial/views/default.py
:lines: 18-23
:lines: 19-24
:lineno-match:
:emphasize-lines: 1-2,4
:language: python
Expand All @@ -171,15 +171,15 @@ the view logic.
Edit the ``edit_page`` view to declare the ``edit`` permission:

.. literalinclude:: src/authorization/tutorial/views/default.py
:lines: 38-42
:lines: 41-45
:lineno-match:
:emphasize-lines: 1-2,4
:language: python

Edit the ``add_page`` view to declare the ``create`` permission:

.. literalinclude:: src/authorization/tutorial/views/default.py
:lines: 52-56
:lines: 55-59
:lineno-match:
:emphasize-lines: 1-2,4
:language: python
Expand Down
2 changes: 0 additions & 2 deletions docs/tutorials/wiki2/src/authorization/.coveragerc

This file was deleted.

4 changes: 0 additions & 4 deletions docs/tutorials/wiki2/src/authorization/CHANGES.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/tutorials/wiki2/src/authorization/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include *.txt *.ini *.cfg *.rst
include *.txt *.ini *.cfg *.rst *.toml
recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2
recursive-include tests *
recursive-exclude * __pycache__
Expand Down
60 changes: 60 additions & 0 deletions docs/tutorials/wiki2/src/authorization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# myproj

## Getting Started

- Change directory into your newly created project if not already there. Your
current directory should be the same as this `README.md` file and `pyproject.toml`.

```
cd tutorial
```

- Create a Python virtual environment, if not already created.

```
python3 -m venv env
```

- Upgrade packaging tools, if necessary.

```
env/bin/pip install --upgrade pip
```

- Install the project in editable mode with its testing requirements.

```
env/bin/pip install -e ".[testing]"
```

- Initialize and upgrade the database using Alembic.

- Generate your first revision.

```
env/bin/alembic -c development.ini revision --autogenerate -m "init"
```
- Upgrade to that revision.
```
env/bin/alembic -c development.ini upgrade head
```
- Load default data into the database using a script.
```
env/bin/initialize_tutorial_db development.ini
```
- Run your project's tests.
```
env/bin/pytest
```
- Run your project.
```
env/bin/pserve development.ini
```
44 changes: 0 additions & 44 deletions docs/tutorials/wiki2/src/authorization/README.txt

This file was deleted.

8 changes: 4 additions & 4 deletions docs/tutorials/wiki2/src/authorization/development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ auth.secret = seekrit
[pshell]
setup = tutorial.pshell.setup

###
# wsgi server configuration
###

[alembic]
# path to migration scripts
script_location = tutorial/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
listen = localhost:6543
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/wiki2/src/authorization/production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ auth.secret = real-seekrit
[pshell]
setup = tutorial.pshell.setup

###
# wsgi server configuration
###

[alembic]
# path to migration scripts
script_location = tutorial/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
listen = *:6543
Expand Down
60 changes: 60 additions & 0 deletions docs/tutorials/wiki2/src/authorization/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
version = "0.0"
name = "tutorial"
authors = []
description = "myproj"
readme = "README.md"
keywords = ["web", "pyramid", "pylons"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
]
requires-python = ">=3.8"
dependencies = [
"alembic",
"bcrypt",
"docutils",
"plaster_pastedeploy",
"pyramid",
"pyramid_debugtoolbar",
"pyramid_jinja2",
"pyramid_retry",
"pyramid_tm",
"SQLAlchemy",
"transaction",
"waitress",
"zope.sqlalchemy",
]

[project.optional-dependencies]
testing = [
"WebTest",
"pytest",
"pytest-cov",
]

[project.scripts]
initialize_tutorial_db = "tutorial.scripts.initialize_db:main"

[project.entry-points."paste.app_factory"]
main = "tutorial:main"

[tool.setuptools.packages.find]
exclude = ["tests"]

[tool.coverage.run]
source = "tutorial"

[tool.pytest.ini_options]
addopts = "--strict-markers"
testpaths = [
"tutorial",
"tests",
]
6 changes: 0 additions & 6 deletions docs/tutorials/wiki2/src/authorization/pytest.ini

This file was deleted.

63 changes: 0 additions & 63 deletions docs/tutorials/wiki2/src/authorization/setup.py

This file was deleted.

8 changes: 4 additions & 4 deletions docs/tutorials/wiki2/src/authorization/testing.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ auth.secret = test-seekrit
[pshell]
setup = tutorial.pshell.setup

###
# wsgi server configuration
###

[alembic]
# path to migration scripts
script_location = tutorial/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
listen = localhost:6543
Expand Down
Loading

0 comments on commit 3c61799

Please sign in to comment.