Context Management
1 Storage Management
Flask support Coroutines by dict and greenlet.getcurrent, it allocates space for each greenlet and store them in a dictionary
- create a dictionary called
__storage__ - set, get from
__storage__usinggreenlet.getcurrentas key
1 | try: |
2 Request Context
- Request context includes request and session
- Basically, each request comes
- Capsulate
environinto aRequestContextobject - Add it into
__storage__dictionary - Dispatch request to each view file and do operation
- Remove it from
__storage__dictionary
- Capsulate
Picture for step 1, 2, 4

Picture for step 3 example

partial(): it is quite funcional programmingobject.__setattr__(self, '_LocalProxy__local', local): stuck here for quite a while. python3 documentation
3 App Context
- It is quite similar as Request Context
- It includes
current_appandg