<s> """<STR_LIT>""" <EOL> from muntjac . terminal . gwt . server . abstract_web_application_context import AbstractWebApplicationContext <EOL> from muntjac . util import clsname <EOL> class WebApplicationContext ( AbstractWebApplicationContext ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( WebApplicationContext , self ) . __init__ ( ) <EOL> self . session = None <EOL> self . _reinitializingSession = False <EOL> self . _currentRequest = None <EOL> def __getstate__ ( self ) : <EOL> result = self . __dict__ . copy ( ) <EOL> del result [ '<STR_LIT>' ] <EOL> del result [ '<STR_LIT>' ] <EOL> del result [ '<STR_LIT>' ] <EOL> return result <EOL> def __setstate__ ( self , d ) : <EOL> self . __dict__ = d <EOL> self . session = None <EOL> self . _reinitializingSession = False <EOL> self . _currentRequest = None <EOL> def startTransaction ( self , application , request ) : <EOL> self . _currentRequest = request <EOL> super ( WebApplicationContext , self ) . startTransaction ( application , <EOL> request ) <EOL> def endTransaction ( self , application , request ) : <EOL> super ( WebApplicationContext , self ) . endTransaction ( application , <EOL> request ) <EOL> self . _currentRequest = None <EOL> def valueUnbound ( self , event ) : <EOL> if not self . _reinitializingSession : <EOL> super ( WebApplicationContext , self ) . valueUnbound ( event ) <EOL> def reinitializeSession ( self ) : <EOL> """<STR_LIT>""" <EOL> oldSession = self . getHttpSession ( ) <EOL> attrs = dict ( ) <EOL> attrs . update ( oldSession . values ) <EOL> self . _reinitializingSession = True <EOL> oldSession . invalidate ( ) <EOL> self . _reinitializingSession = False <EOL> newSession = self . _currentRequest . session ( ) <EOL> for name , val in attrs . iteritems ( ) : <EOL> newSession . setValue ( name , val ) <EOL> self . session = newSession <EOL> def getBaseDirectory ( self ) : <EOL> """<STR_LIT>""" <EOL> realPath = self . getResourcePath ( self . session , '<STR_LIT:/>' ) <EOL> if realPath is None : <EOL> return None <EOL> return realPath <EOL> def getHttpSession ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . session <EOL> @ classmethod <EOL> def getApplicationContext ( cls , session , servlet ) : <EOL> """<STR_LIT>""" <EOL> cx = servlet . getSessionAttribute ( session , <EOL> clsname ( WebApplicationContext ) , None ) <EOL> if cx is None : <EOL> cx = WebApplicationContext ( ) <EOL> servlet . setSessionAttribute ( session , <EOL> clsname ( WebApplicationContext ) , cx ) <EOL> if cx . session is None : <EOL> cx . session = session <EOL> return cx <EOL> def addApplication ( self , application ) : <EOL> self . applications . add ( application ) <EOL> def getApplicationManager ( self , application , servlet ) : <EOL> """<STR_LIT>""" <EOL> mgr = self . applicationToAjaxAppMgrMap . get ( application ) <EOL> if mgr is None : <EOL> mgr = servlet . createCommunicationManager ( application ) <EOL> self . applicationToAjaxAppMgrMap [ application ] = mgr <EOL> return mgr </s>
