def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
 if (session_setting is None):
  return request_setting
 if (request_setting is None):
  return session_setting
 if (not (isinstance(session_setting, Mapping) and isinstance(request_setting, Mapping))):
  return request_setting
 merged_setting = dict_class(to_key_val_list(session_setting))
 merged_setting.update(to_key_val_list(request_setting))
 for (k, v) in request_setting.items():
  if (v is None):
   del merged_setting[k]
 merged_setting = dict(((k, v) for (k, v) in merged_setting.items() if (v is not None)))
 return merged_setting

def merge_setting ( request_setting , session_setting , dict_class = OrderedDict ) : if ( session_setting is None ) : return request_setting if ( request_setting is None ) : return session_setting if ( not ( isinstance ( session_setting , Mapping ) and isinstance ( request_setting , Mapping ) ) ) : return request_setting merged_setting = dict_class ( to_key_val_list ( session_setting ) ) merged_setting . update ( to_key_val_list ( request_setting ) ) for ( k , v ) in request_setting . items ( ) : if ( v is None ) : del merged_setting [ k ] merged_setting = dict ( ( ( k , v ) for ( k , v ) in merged_setting . items ( ) if ( v is not None ) ) ) return merged_setting
determines appropriate setting for a given request .