Package expedient :: Package common :: Package middleware :: Module threadlocals
[hide private]
[frames] | no frames]

Module threadlocals

source code


Author: jnaous

Classes [hide private]
  threadlocal
  ParserRedefined
Raised when models.ThreadLocals.add_parser is called twice for the same keyword.
  ThreadLocals
Middleware that gets various objects from the request object and saves them in thread local storage.
Functions [hide private]
 
push_frame(**kw)
Push a new frame on the stack.
source code
 
pop_frame()
Pop a frame from the stack.
source code
 
get_thread_locals()
Returns the dictionary of all parsed keywords in the request.
source code
 
add_parser(kw, func)
Add a request parser for a keyword.
source code
 
get_parser(kw)
Get the parser function stored for the keyword kw or None if it doesn't exist.
source code
Variables [hide private]
  _thread_locals = threadlocal()
  __package__ = 'expedient.common.middleware'
Function Details [hide private]

add_parser(kw, func)

source code 

Add a request parser for a keyword. When a request arrives, the parser func will be used to set the value for the kw keyword in the thread-local storage.

Parameters:
  • kw (hashable value) - The keyword to use for the result of this parser.
  • func (callable.) - a function that accepts the request and returns a value