<s> import os <EOL> from pyramid . httpexceptions import HTTPFound <EOL> from pyramid . view import view_config <EOL> from pyramid_notebook import startup <EOL> from pyramid_notebook . views import launch_notebook <EOL> from pyramid_notebook . views import shutdown_notebook as _shutdown_notebook <EOL> from pyramid_notebook . views import notebook_proxy as _notebook_proxy <EOL> from websauna . system . model . meta import Base <EOL> WEBSAUNA_BOOSTRAP = """<STR_LIT>""" <EOL> SCRIPT = """<STR_LIT>""" <EOL> GREETING = """<STR_LIT>""" <EOL> def launch_context_sensitive_shell ( request , extra_script = "<STR_LIT>" , extra_greeting = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> nb = { } <EOL> global_config = request . registry . settings [ "<STR_LIT>" ] <EOL> config_file = global_config [ "<STR_LIT>" ] <EOL> startup . make_startup ( nb , config_file , bootstrap_py = WEBSAUNA_BOOSTRAP , cwd = os . getcwd ( ) ) <EOL> startup . add_script ( nb , SCRIPT ) <EOL> startup . add_greeting ( nb , GREETING ) <EOL> startup . include_sqlalchemy_models ( nb , Base ) <EOL> startup . add_script ( nb , extra_script ) <EOL> startup . add_greeting ( nb , extra_greeting ) <EOL> return launch_notebook ( request , request . user . username , notebook_context = nb ) <EOL> @ view_config ( route_name = "<STR_LIT>" , permission = "<STR_LIT>" , require_csrf = False ) <EOL> def notebook_proxy ( request ) : <EOL> """<STR_LIT>""" <EOL> return _notebook_proxy ( request , request . user . username ) <EOL> @ view_config ( route_name = "<STR_LIT>" , permission = "<STR_LIT>" ) <EOL> def admin_shell ( request ) : <EOL> """<STR_LIT>""" <EOL> return launch_context_sensitive_shell ( request ) <EOL> @ view_config ( route_name = "<STR_LIT>" , permission = "<STR_LIT>" ) <EOL> def shutdown_notebook ( request ) : <EOL> """<STR_LIT>""" <EOL> _shutdown_notebook ( request , request . user . username ) <EOL> return HTTPFound ( request . route_url ( "<STR_LIT>" ) ) </s>
