Skip to content

39. Conclusion

Let’s review the work done in this document:

Chapter
Code Repository
Contents
   
 
Course Overview
 
Setting up a work environment
[Basics]
The basics of the Python language
– language structures – data types
– functions – console output –
format strings – type conversion
– lists – dictionaries – regular
expressions
[strings]
String notation – methods of the
<str> class – encoding/decoding
strings in UTF-8
[exceptions]
Exception handling
[functions]
Variable Scope – Parameter
Passing – Using Modules – The
Python Path – Named
Parameters – Recursive
Functions
[files]
Reading/writing a text file –
handling UTF-8 encoded files –
handling JSON files
[taxes/v01]
Version 1 of the application
exercise: calculating income tax
. The application is available in 18
versions – Version 1 implements
a procedural solution
[imports]
Managing application
dependencies by importing
modules – a dependency
management method is presented
– it is used throughout the
document – managing the
Python Path
[impots/v02]
Version 2 of the application
builds on version 1 by gathering
all configuration constants into a
configuration file that also
manages the Python Path
[impots/v03]
Version 3 of the application
builds on version 2 by using
functions encapsulated in a
module— dependency
management is handled via
configuration—introduction of a
JSON file to read the data needed
for tax calculation and write the
calculation results
[classes/01]
Classes – inheritance – methods
and properties – getters/setters –
constructor – [__dict__]
property
[classes/02]
Introduction to the [BaseEntity]
and [MyException] classes used
throughout the rest of the
document – [BaseEntity]
facilitates object/dictionary
conversions
[three-layers]
Layered architecture and
interface-based programming.
This chapter presents the
programming methods used
throughout the rest of the
document
[taxes/v04]
Version 4 of the application – this
version implements a solution
with a layered architecture,
interface-based programming, and
the use of classes derived from
[BaseEntity] and
[MyException]
[databases/mysql]
Installing the MySQL DBMS –
connecting to a database –
creating a table – executing
SELECT, UPDATE, DELETE,
and INSERT SQL statements –
transactions – parameterized
SQL queries
[databases/postgresql]
Installing the PostgreSQL DBMS
– connecting to a database –
creating a table – executing
SELECT, UPDATE, DELETE,
and INSERT SQL statements –
transactions – parameterized
SQL queries
[databases/anydbms]
Writing DBMS-independent code
[databases/sqlalchemy]
The SqlAlchemy ORM (Object-
Relational Mapper) – an ORM
allows for a unified approach to
working with different DBMSs –
mapping classes to SQL tables –
operations on classes
representing SQL tables
[taxes/v05]
Version 5 of the tax calculation
application – Using the layered
architecture from version 04 and
the SqlAlchemy ORM to work
with MySQL and PostgreSQL
DBMSs
[inet]
Web Programming – TCP/IP
Protocol (Transmission Control
Protocol / Internet Protocol) –
HTTP Protocols (HyperText
Transfer Protocol) – SMTP
(Simple Mail Transfer Protocol)
– POP (Post Office Protocol) –
IMAP (Internet Message Access
Protocol)
[flask]
Web services with the Flask web
framework – displaying an
HTML page – JSON web service
– GET and POST requests –
managing a web session
[impots/http-servers/01]
[taxes/http-clients/01]
Version 6 of the application
exercise – Creating a JSON web
service for tax calculation with a
multi-layer architecture – Writing
a web client for this server with a
multi-layer architecture –
client/server programming –
using the [requests] module
[taxes/http-servers/02]
[taxes/http-clients/02]
Version 7 of the application
exercise – Version 6 is improved:
the client and server are
multithreaded – [Logger]
utilities to log client/server
exchanges – [SendMail] to send
an email to the application
administrator
[taxes/http-servers/03]
[taxes/http-clients/03]
Version 8 of the application
exercise – Version 7 is improved
by the use of a web session
[xml]
XML (eXtended Markup
Language) management with the
[xmltodict] module
[taxes/http-servers/04]
[impots/http-clients/04]
Version 9 of the application
exercise – version 8 is modified
to include client/server
exchanges in XML;
[taxes/http-servers/05]
[taxes/http-clients/05]
Version 10 of the application
exercise – instead of processing N
taxpayers via N GET requests, a
single POST request is used with
the N taxpayers in the POST
body
[taxes/http-servers/06]
[taxes/http-clients/06]
Version 11 of the application
exercise – the application’s
client/server architecture is
modified: the [business] layer
moves from the server to the
client
[taxes/http-servers/07]
Version 12 of the application
exercise – this version implements
an MVC (Model–View–
Controller) server that delivers
JSON, XML, and HTML
interchangeably, depending on
the client’s request. This chapter
implements the JSON and XML
versions of the server
[impots/http-clients/07]
Implementation of the JSON and
XML clients for the MVC server
in Version 12
[impots/http-servers/07]
Implementation of the HTML
server in version 12 – using the
Bootstrap CSS framework –
[impots/http-servers/08]
Version 13 of the application
exercise – Refactoring the code
from version 12 – session
management using the
[flask_session] module and a
Redis server – using encrypted
passwords
[impots/http-servers/09]
[impots/http-clients/09]
Version 14 of the application
exercise – implementing URLs
with a CSRF (Cross-Site Request
Forgery) token
[impots/http-servers/10]
Version 15 of the application
exercise – refactoring the code
from version 14 to handle two
types of actions: ASV (Action
Show View), which are used only
to display a view without
modifying the server’s state, and
ADS (Action Do Something),
which perform an action that
modifies the server’s state—these
actions all end with a redirect to
an ASV action—this allows for
proper handling of page refreshes
in the client browser
[impots/http-servers/11]
Version 16 of the application –
URL management with prefixes
[impots/http-servers/12]
Version 17 of the application –
porting version 16 to an
Apache/Windows server
[impots/http-servers/13]
Version 18 of the application –
fixes a bug in version 17

The client/server tax calculation applications have implemented the following architecture:

Image

The [web] layer above was implemented using an MVC architecture:

Image

The content of this document is dense. Readers who make it to the end will gain a solid understanding of MVC web programming in Python/Flask and, beyond that, a solid understanding of MVC web programming in other languages.

Additional information on the Flask framework can be found in the document [https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world] by the author Miguel Grinberg. I have read some sections of his course, and they struck me as very educational. The author covers many concepts not addressed in this document.