Book Image

Mastering Python Design Patterns

By : Sakis Kasampalis
Book Image

Mastering Python Design Patterns

By: Sakis Kasampalis

Overview of this book

Table of Contents (23 chapters)
Mastering Python Design Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
The Factory Pattern
Index

A software example


The Django framework uses decorators to a great extent. An example is the View decorator. Django's View decorators can be used for [j.mp/djangodec]:

  • Restricting access to views based on the HTTP request

  • Controlling the caching behavior on specific views

  • Controlling compression on a per-view basis

  • Controlling caching based on specific HTTP request headers

The Grok framework also uses decorators for achieving different goals such as [j.mp/grokdeco]:

  • Registering a function as an event subscriber

  • Protecting a method with a specific permission

  • Implementing the Adapter pattern