8.3.4 The BranchingSessionContext Class

The BranchingSessionContext class is intended to be used with the server-side session application classes. It creates a new session for each interaction with the client, and stores the session identifier in a hidden form field. This allows us to detect when the browser state rolls back (via the browser back button), and find the appropriate session context, giving an effect like the client-side SimpleAppContext without storing the entire context in a hidden form field.

Figure: The BranchingSessionContext class
\includegraphics{branchingsessioncontext}

The methods available in BranchingSessionContext and the location of their definition are show below.

Method Mixin
absolute_base_url() AppContext
add_header(name, value) ResponseMixin
add_session_vars(*names) SessionBase
base_url() AppContext
clear_locals() AppContext
current_url() AppContext
decode_session(text) SessionBase
default_session_var(name, value) SessionBase
del_header(name) ResponseMixin
del_session_vars(*names) SessionBase
encode_session() SessionBase
eval_expr(expr) NamespaceMixin
flush_content() ExecuteMixin
flush_html() ExecuteMixin
form_close() BranchingSessionContext
form_open() NameRecorderMixin
get_header(name) ResponseMixin
get_lookup(name) AppContext
get_macro(name) AppContext
get_macro_arg(name) ExecuteMixin
get_tagclass(name) AppContext
get_value(name) NamespaceMixin
has_value(name) NamespaceMixin
has_values(*names) NamespaceMixin
input_add(itype, name, unused_value, return_list) NameRecorderMixin
load_session() BranchingSessionMixin
load_template(name) AppContext
load_template_once(name) AppContext
make_alias(name) NamespaceMixin
merge_request() NameRecorderMixin
parsed_request_uri() AppContext
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_page(target_page) AppContext
push_content_trap() ExecuteMixin
push_macro_args(args) ExecuteMixin
push_page(name, *args) AppContext
redirect(loc) AppContext
redirect_url(loc) AppContext
register_lookup(name, lookup) AppContext
register_macro(name, macro) AppContext
remove_session() BranchingSessionMixin
req_equals(name) AppContext
reset_content() ExecuteMixin
run_template(name) AppContext
run_template_once(name) AppContext
save_session() BranchingSessionMixin
send_content(data) ResponseMixin
send_redirect(loc) ResponseMixin
sesid() BranchingSessionMixin
session_vars() SessionBase
set_globals(dict) NamespaceMixin
set_header(name, value) ResponseMixin
set_page(name, *args) AppContext
set_request(req) AppContext
set_save_session(flag) SessionBase
set_value(name, value) NamespaceMixin
should_save_session() SessionBase
txid() BranchingSessionMixin
write_content(data) ExecuteMixin
write_headers() ResponseMixin

Externally the execution context is almost identical to that of the SimpleAppContext class. Instead of saying the session data in hidden HTML fields, the session identifier is stored in a hidden field, and the session data is saved and loaded from the session server.

The class defines a number of extra methods:

__init__( app)
When you inherit from the BranchingSessionContext class you must call this constructor.

The app argument is passed to the AppContext constructor.

form_close( )
Invokes the form_close() method of the NameRecorderMixin class and encode_session() of the BranchingSessionMixin class.