#NEWLINE# def filters_from_request( request ) : #NEWLINE# #INDENT# raw_filters = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for key in request . POST : #NEWLINE# #INDENT# splt = key . split ( '-' ) #NEWLINE# if splt [ 0 ] . startswith ( 'filter' ) : #NEWLINE# #INDENT# ident = splt [ 1 ] #NEWLINE# typ = splt [ 2 ] #NEWLINE# if ( not ( ident in splt ) ) : #NEWLINE# #INDENT# raw_filters [ ident ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# raw_filters [ ident ] [ typ ] = request . POST [ key ] #NEWLINE# #UNINDENT# #UNINDENT# filters = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( ident , raw_filter ) in raw_filters . items ( ) : #NEWLINE# #INDENT# value = raw_filter . get ( 'value' , '' ) #NEWLINE# if value . strip ( ) : #NEWLINE# #INDENT# typ = raw_filter [ 'typ' ] #NEWLINE# module = _get_module ( 'silk.request_filters' ) #NEWLINE# filter_class = getattr ( module , typ ) #NEWLINE# try : #NEWLINE# #INDENT# f = filter_class ( value ) #NEWLINE# filters [ ident ] = f #NEWLINE# #UNINDENT# except FilterValidationError : #NEWLINE# #INDENT# logger . warn ( ( 'Validation error when processing filter %s(%s)' % ( typ , value ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return filters