#NEWLINE# def process_request( self , req ) : #NEWLINE# #INDENT# if ( req . is_xhr and ( req . method == 'POST' ) and ( 'save_prefs' in req . args ) ) : #NEWLINE# #INDENT# self . _do_save_xhr ( req ) #NEWLINE# #UNINDENT# ( panels , providers ) = self . _get_panels ( req ) #NEWLINE# if ( not panels ) : #NEWLINE# #INDENT# raise HTTPNotFound ( _ ( 'No preference panels available' ) ) #NEWLINE# #UNINDENT# panels = [ ] #NEWLINE# child_panels = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# providers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for provider in self . panel_providers : #NEWLINE# #INDENT# for panel in ( provider . get_preference_panels ( req ) or [ ] ) : #NEWLINE# #INDENT# if ( len ( panel ) == 3 ) : #NEWLINE# #INDENT# ( name , label , parent ) = panel #NEWLINE# child_panels . setdefault ( parent , [ ] ) . append ( ( name , label ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# name = panel [ 0 ] #NEWLINE# panels . append ( panel ) #NEWLINE# #UNINDENT# providers [ name ] = provider #NEWLINE# #UNINDENT# #UNINDENT# panels = sorted ( panels ) #NEWLINE# panel_id = req . args . get ( 'panel_id' ) #NEWLINE# if ( panel_id is None ) : #NEWLINE# #INDENT# panel_id = ( panels [ 1 ] [ 0 ] if ( ( len ( panels ) > 1 ) and ( panels [ 0 ] [ 0 ] == 'advanced' ) ) else panels [ 0 ] [ 0 ] ) #NEWLINE# #UNINDENT# chosen_provider = providers . get ( panel_id ) #NEWLINE# if ( not chosen_provider ) : #NEWLINE# #INDENT# raise HTTPNotFound ( _ ( "Unknown preference panel '%(panel)s'" , panel = panel_id ) ) #NEWLINE# #UNINDENT# session_data = { #NEWLINE# #INDENT# 'session' : req . session , #NEWLINE# 'settings' : { #NEWLINE# #INDENT# 'session' : req . session , #NEWLINE# 'session_id' : req . session . sid , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# chrome = Chrome ( self . env ) #NEWLINE# children = [ ] #NEWLINE# if child_panels . get ( panel_id ) : #NEWLINE# #INDENT# for ( name , label ) in child_panels [ panel_id ] : #NEWLINE# #INDENT# ( ctemplate , cdata ) = provider . render_preference_panel ( req , name ) #NEWLINE# cdata . update ( session_data ) #NEWLINE# rendered = chrome . render_template ( req , ctemplate , cdata , fragment = True ) #NEWLINE# children . append ( ( chosen_provider , label , rendered ) ) #NEWLINE# #UNINDENT# #UNINDENT# ( template , data ) = chosen_provider . render_preference_panel ( req , panel_id ) #NEWLINE# data . update ( session_data ) #NEWLINE# data . update ( { #NEWLINE# #INDENT# 'active_panel' : panel_id , #NEWLINE# 'panels' : panels , #NEWLINE# 'children' : children , #NEWLINE# #UNINDENT# } ) #NEWLINE# add_stylesheet ( req , 'common/css/prefs.css' ) #NEWLINE# return ( template , data , None )