"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/patterns/viewdecorators.rst" between
flask-1.1.1.tar.gz and flask-1.1.2.tar.gz

About: Flask is a lightweight Python WSGI web application framework.

viewdecorators.rst  (flask-1.1.1):viewdecorators.rst  (flask-1.1.2)
skipping to change at line 72 skipping to change at line 72
Here is an example cache function. It generates the cache key from a Here is an example cache function. It generates the cache key from a
specific prefix (actually a format string) and the current path of the specific prefix (actually a format string) and the current path of the
request. Notice that we are using a function that first creates the request. Notice that we are using a function that first creates the
decorator that then decorates the function. Sounds awful? Unfortunately decorator that then decorates the function. Sounds awful? Unfortunately
it is a little bit more complex, but the code should still be it is a little bit more complex, but the code should still be
straightforward to read. straightforward to read.
The decorated function will then work as follows The decorated function will then work as follows
1. get the unique cache key for the current request base on the current 1. get the unique cache key for the current request based on the current
path. path.
2. get the value for that key from the cache. If the cache returned 2. get the value for that key from the cache. If the cache returned
something we will return that value. something we will return that value.
3. otherwise the original function is called and the return value is 3. otherwise the original function is called and the return value is
stored in the cache for the timeout provided (by default 5 minutes). stored in the cache for the timeout provided (by default 5 minutes).
Here the code:: Here the code::
from functools import wraps from functools import wraps
from flask import request from flask import request
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)