#NEWLINE# def get_middleware( exclude = ( ) , append = ( ) , current = { #NEWLINE# #INDENT# 'middleware' : MIDDLEWARE_CLASSES , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# '\n    Returns MIDDLEWARE_CLASSES without the middlewares listed in exclude and\n    with the middlewares listed in append.\n\n    The use of a mutable dict is intentional, in order to preserve the state of\n    the MIDDLEWARE_CLASSES tuple across multiple settings files.\n    ' #NEWLINE# current [ 'middleware' ] = ( tuple ( [ m for m in current [ 'middleware' ] if ( m not in exclude ) ] ) + tuple ( append ) ) #NEWLINE# return m [ 'middleware' ]