Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ Where necessary, each chapter has it's own `README.md` file that explains how to
### Chapters with README files

- Groundwork
- [Chapter 4](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_04) - Where Developers and Computers Meet
- [Chapter 5](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_05) - The Object of a Conversation
- [Chapter 6](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_06) - Exceptional Events
- [Chapter 3](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_03) - The API, Where Developers and Computers Meet
- [Chapter 4](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_04) - The Object of a Conversation
- [Chapter 5](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_05) - Exceptional Events, Let's Handle Them
- Fieldwork
- [Chapter 7](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_07) - Sharing With the World
- [Chapter 8](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_08) - Doing it With Style
- [Chapter 9](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_09) - Do I Know You?
- [Chapter 10](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_10) - Persistence Means Never Having to say Goodbye
- [Chapter 11](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_11) - I've Got Something to Say
- [Chapter 6](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_06) - Sharing With the Internet
- [Chapter 7](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_07) - Doing it With Style
- [Chapter 8](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_08) - Do I Know You? Authentication
- [Chapter 9](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_09) - I Know You, What Would You Like To Do? Authorization
- [Chapter 10](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_10) - Persistence Means Never Having to say Goodbye, at Least With a Database
- [Chapter 11](https://github.com/writeson/the-well-grounded-python-developer/tree/integration/examples/CH_11) - I've Got Something to Say, and I'm Going to Blog About it

![visitors](https://visitor-badge.laobi.icu/badge?page_id=Ria700.Ria700)
6 changes: 3 additions & 3 deletions examples/CH_03/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Chapter 4 Example Programs
# Chapter 3 Example Programs

This directory contains the Chapter 4 examples from the book and scripts to install and run those examples.
This directory contains the Chapter 3 examples from the book and scripts to install and run those examples.

## Installation

You will need a Python virtual environment to run the programs so that any modules installed by the setup won't interfere with your system Python. The instructions here depend on having the `pyenv` utility installed on your system. To activate a Python virtual environment in this directory take the following steps:

```console
$ cd CH_04
$ cd CH_03
$ pyenv local 3.10.3
$ python -m venv .venv
$ source .venv/bin/activate
Expand Down
6 changes: 3 additions & 3 deletions examples/CH_04/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Chapter 5 Example Programs
# Chapter 4 Example Programs

This directory contains the Chapter 5 examples from the book and scripts to install and run those examples.
This directory contains the Chapter 4 examples from the book and scripts to install and run those examples.

## Installation

You will need a Python virtual environment to run the programs so that any modules installed by the setup won't interfere with your system Python. The instructions here depend on having the `pyenv` utility installed on your system. To activate a Python virtual environment in this directory take the following steps:

```console
$ cd CH_05
$ cd CH_04
$ pyenv local 3.10.3
$ python -m venv .venv
$ source .venv/bin/activate
Expand Down
14 changes: 7 additions & 7 deletions examples/CH_04/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
arcade==2.6.9
attrs==21.4.0
cffi==1.15.0
arcade==2.6.17
attrs==22.2.0
cffi==1.15.1
Pillow==9.3.0
pycparser==2.21
pyglet==2.0.dev13
pymunk==6.2.1
pytiled-parser==2.0.1
typing_extensions==4.0.1
pyglet==2.0.dev23
pymunk==6.4.0
pytiled-parser==2.2.0
typing_extensions==4.5.0
14 changes: 3 additions & 11 deletions examples/CH_05/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Chapter 6 Example Programs
# Chapter 5 Example Programs

This directory contains the Chapter 6 examples from the book and scripts to install and run those examples.
This directory contains the Chapter 5 examples from the book and scripts to install and run those examples.

## Installation

You will need a Python virtual environment to run the programs so that any modules installed by the setup won't interfere with your system Python. The instructions here depend on having the `pyenv` utility installed on your system. To activate a Python virtual environment in this directory take the following steps:

```console
$ cd CH_06
$ cd CH_05
$ pyenv local 3.10.3
$ python -m venv .venv
$ source .venv/bin/activate
Expand All @@ -16,14 +16,6 @@ $ pip install --upgrade pip

Once you have a local Python virtual environment activated your command prompt should be prefixed with `(.venv)`. This indicates the Python system in the current directory is active and ready to run.

To install the modules necessary for this chapter, run the following command line while your Python virtual environment is active:

```
pip install -r requirements.txt
```

The command will pip install any modules necessary to run the example programs in the chapter and create shortcuts to run the example programs.

## Example Programs

- 01 - demonstrates generating an exception and letting it bubble upward till the program exits.
Expand Down
8 changes: 4 additions & 4 deletions examples/CH_06/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Chapter 7 Example Programs
# Chapter 6 Example Programs

This directory contains the Chapter 7 examples from the book and scripts to install and run those examples.
This directory contains the Chapter 6 examples from the book and scripts to install and run those examples.

## Installation

You will need a Python virtual environment to run the programs so that any modules installed by the setup won't interfere with your system Python. The instructions here depend on having the `pyenv` utility installed on your system. To activate a Python virtual environment in this directory take the following steps:

```console
$ cd CH_07
$ cd CH_06
$ pyenv local 3.10.3
$ python -m venv .venv
$ source .venv/bin/activate
Expand All @@ -26,4 +26,4 @@ pip install -r requirements.txt

- 01 - demonstrates a simple "Hello World" web application
- 02 - demonstrates a web application with dynamically updated data
- 03 - demonstrates a web application with dynamically updated data and user interaction
- 03 - demonstrates a web application with dynamically updated data and user interactive
10 changes: 5 additions & 5 deletions examples/CH_06/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
click==8.0.3
Flask==2.0.2
click==8.0.4
Flask==2.0.3
gunicorn==20.1.0
itsdangerous==2.0.1
itsdangerous==2.1.0
Jinja2==3.0.3
MarkupSafe==2.0.1
MarkupSafe==2.1.1
waitress==2.1.2
Werkzeug==2.0.2
Werkzeug==2.2.3
4 changes: 2 additions & 2 deletions examples/CH_07/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chapter 8 Example Programs
# Chapter 7 Example Programs

This directory contains the Chapter 8 examples from the book and scripts to install and run those examples.
This directory contains the Chapter 7 examples from the book and scripts to install and run those examples.

## Installation

Expand Down
10 changes: 5 additions & 5 deletions examples/CH_07/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
blinker==1.4
click==8.0.3
click==8.0.4
dynaconf==3.1.7
Flask==2.0.2
Flask==2.0.3
Flask-DebugToolbar==0.11.0
gunicorn==20.1.0
itsdangerous==2.0.1
itsdangerous==2.1.0
Jinja2==3.0.3
MarkupSafe==2.0.1
MarkupSafe==2.1.1
PyYAML==6.0
waitress==2.1.2
Werkzeug==2.0.2
Werkzeug==2.2.3
8 changes: 3 additions & 5 deletions examples/CH_08/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Chapter 9 Example Programs
# Chapter 8 Example Programs

This directory contains the Chapter 9 examples from the book and scripts to install and run those examples.
This directory contains the Chapter 8 examples from the book and scripts to install and run those examples.

## Installation

You will need a Python virtual environment to run the programs so that any modules installed by the setup won't interfere with your system Python. The instructions here depend on having the `pyenv` utility installed on your system. To activate a Python virtual environment in this directory take the following steps:

```console
$ cd CH_09
$ cd CH_08
$ pyenv local 3.10.3
$ python -m venv .venv
$ source .venv/bin/activate
Expand All @@ -29,5 +29,3 @@ The command will pip install any modules necessary to run the example programs i
- 01 Adds the Flask-Login module and creates a login screen
- 02 Adds a handler for any Flask flash messages generated by using Bootstrap toasts
- 03 Adds a new user registration form to create users
- 04 Adds a test page only logged in users can access, and another page only administrator uses can access. Also adds 'login/logout' to the application navigation
- 05 Adds a system to send a confirmation email to new users, a way for users to reset their password and a profile page
32 changes: 16 additions & 16 deletions examples/CH_08/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
alembic==1.7.5
bcrypt==3.2.0
blinker==1.4
cachetools==4.2.4
cachetools==5.0.0
certifi==2022.12.7
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.8
charset-normalizer==2.0.12
click==8.0.3
cryptography==36.0.1
cryptography==39.0.1
cssselect==1.1.0
cssutils==2.3.0
dnspython==2.1.0
dnspython==2.2.0
dynaconf==3.1.7
email-validator==1.1.3
Flask==2.0.2
Flask-Bcrypt==0.7.1
Flask==2.0.3
Flask-Bcrypt==1.0.1
Flask-DebugToolbar==0.11.0
Flask-Login==0.5.0
Flask-Login==0.6.2
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.0.0
greenlet==1.1.2
greenlet==2.0.2
gunicorn==20.1.0
idna==3.3
itsdangerous==2.0.1
itsdangerous==2.1.0
Jinja2==3.0.3
lxml==4.9.1
mako==1.2.2
MarkupSafe==2.0.1
Mako==1.2.2
MarkupSafe==2.1.1
premailer==3.10.0
pycparser==2.21
pyjwt==2.4.0
PyJWT==2.4.0
python-dateutil==2.8.2
python-editor==1.0.4
PyYAML==6.0
requests==2.26.0
requests==2.28.2
six==1.16.0
SQLAlchemy==1.4.27
urllib3==1.26.7
urllib3==1.26.8
waitress==2.1.2
Werkzeug==2.0.2
WTForms==3.0.0
Werkzeug==2.2.3
WTForms==3.0.1
8 changes: 3 additions & 5 deletions examples/CH_09/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ The command will pip install any modules necessary to run the example programs i

## Example Programs

- 01 Adds the Flask-Login module and creates a login screen
- 02 Adds a handler for any Flask flash messages generated by using Bootstrap toasts
- 03 Adds a new user registration form to create users
- 04 Adds a test page only logged in users can access, and another page only administrator uses can access. Also adds 'login/logout' to the application navigation
- 05 Adds a system to send a confirmation email to new users, a way for users to reset their password and a profile page
- 01 Adds a test page only logged in users can access, and another page only administrator uses can access. Also adds 'login/logout' to the application navigation
- 02 Adds a register new user and reset password page
- 03 Adds a system to send a confirmation email to new users, a way for users to reset their password and a profile page
16 changes: 8 additions & 8 deletions examples/CH_09/examples/03/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import logging
import logging.config
import os
import yaml
from pathlib import Path
from flask import Flask, send_from_directory

import yaml
from dynaconf import FlaskDynaconf
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask import Flask, send_from_directory
from flask_bcrypt import Bcrypt
import logging
import logging.config
from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy

login_manager = LoginManager()
login_manager.login_view = "auth_bp.login"
Expand Down Expand Up @@ -43,8 +44,7 @@ def favicon():
_configure_logging(app, dynaconf)

# import the routes
from . import intro
from . import auth
from . import auth, intro

# register the blueprints
app.register_blueprint(intro.intro_bp)
Expand Down
13 changes: 6 additions & 7 deletions examples/CH_09/examples/03/app/auth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,16 @@ class ResendConfirmationForm(FlaskForm):
max=128,
message="Email must be between 4 and 128 characters long"
), Email()],
render_kw={"placeholder": " ", "tabindex": 1}
)
cancel = SubmitField("Cancel", render_kw={"tabindex": 3, "autofocus": True}
render_kw={"placeholder": " ", "tabindex": 1, "autofocus": True}
)
cancel = SubmitField("Cancel", render_kw={"tabindex": 3})


class UserProfileForm(FlaskForm):
first_name = StringField(
"First Name",
validators=[DataRequired()],
render_kw={"placeholder": " ", "tabindex": 1, "readonly": True, "autofocus": True}
render_kw={"placeholder": " ", "tabindex": 1, "readonly": True}
)
last_name = StringField(
"Last Name",
Expand All @@ -126,7 +125,7 @@ class UserProfileForm(FlaskForm):
),
EqualTo("confirm_password", message="Passwords must match")
],
render_kw={"placeholder": " ", "tabindex": 4}
render_kw={"placeholder": " ", "tabindex": 4, "autofocus": True}
)
confirm_password = PasswordField(
"Confirm Password",
Expand All @@ -148,9 +147,9 @@ class RequestResetPasswordForm(FlaskForm):
max=128,
message="Email must be between 4 and 128 characters long"
), Email()],
render_kw={"placeholder": " ", "tabindex": 1}
render_kw={"placeholder": " ", "tabindex": 1, "autofocus": True}
)
cancel = SubmitField("Cancel", render_kw={"tabindex": 3, "autofocus": True})
cancel = SubmitField("Cancel", render_kw={"tabindex": 3})


class ResetPasswordForm(FlaskForm):
Expand Down
3 changes: 2 additions & 1 deletion examples/CH_09/examples/03/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def initialize_role_table():
"description": "administrator user with access to all of the application",
"raw_permissions": (
Role.Permissions.REGISTERED |
Role.Permissions.EDITOR | Role.Permissions.ADMINISTRATOR
Role.Permissions.EDITOR |
Role.Permissions.ADMINISTRATOR
).value
}
]
Expand Down
8 changes: 6 additions & 2 deletions examples/CH_09/examples/03/app/static/js/base.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/**
* This self-invoking function displays all the Flask flash
* messages that are queued up.
*/
(function() {
var option = {
const option = {
animation: true,
delay: 3000
}
var toastElements = [].slice.call(document.querySelectorAll('.toast'))
toastElements.map(function (toastElement) {
toastElements.map((toastElement) => {
toast = new bootstrap.Toast(toastElement, option)
toast.show()
})
Expand Down
Loading