Skip to Content
Secret Recipes of the Python Ninja
book

Secret Recipes of the Python Ninja

by Cody Jackson
May 2018
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 37m
English
Packt Publishing
Content preview from Secret Recipes of the Python Ninja

How it works...

Once the Flask modules are imported, the login decorator function provides the main logic for handling user authentication. The Python standard library's @wraps() decorator call does the same thing we have done previously with the def wrapper() function, except we are utilizing the functools.wraps function provided by Flask. This is necessary because the login decorator wraps and replaces the original function; without a wrapper, that original data would be lost during the handover.

The decorated_function() takes any number of arguments, either as positional or keyword:value pairs. This function first checks to see whether the global object g.user is None, that is, a user not logged in. If this is the case, the user is automatically ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Expanding World of Python

The Expanding World of Python

Dane Hillard

Publisher Resources

ISBN: 9781788294874Supplemental Content