Skip to Content
Mastering Object-oriented Python
book

Mastering Object-oriented Python

by Steven F. Lott
April 2014
Beginner to intermediate
634 pages
15h 22m
English
Packt Publishing
Content preview from Mastering Object-oriented Python

Using Callable classes for WSGI applications

We can implement WSGI applications as Callable objects instead of standalone functions. This allows us to have stateful processing in our WSGI server without the potential confusion of global variables. In our previous example, the get_spin() WSGI application relied on two global variables, american and european. The binding between the application and global can be mysterious.

The point of defining a class is to encapsulate the processing and data into a single package. We can use Callable objects to encapsulate our applications in a better manner. This can make the binding between stateful Wheel and WSGI applications clearer. Here is an extension to the Wheel class that makes it into a callable WSGI ...

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

Mastering Object-Oriented Python - Second Edition

Mastering Object-Oriented Python - Second Edition

Steven F. Lott

Publisher Resources

ISBN: 9781783280971Supplemental Content