Prepackaged Application and Execution Context Classes

While Albatross invites you to “roll your own”, in most cases you will use one of the prepackaged Application and Context classes. There are two primary choices to be made when selecting an Application class: the page model and the context model. The page model offers three choices:

  • simple

    The simple model is intended for use in monolithic applications. Page logic is represented by classes.

  • modular

    The modular model defines page logic in a collection of Python models, one per page.

  • random

    The random model extends the modular model, however the current page module is selected via the URI in the browser request.

There are four context models:

  • hidden-field

    The hidden-field model stores session state in the user’s browser in hidden HTML fields.

  • session-server

    The session-server model stores session state on the server using a separate session server process. An HTTP cookie is used to match a user session to their state on the server.

  • session-file

    Similar to the session-server model, the session-file model stores session state on the server. However, rather than requiring a session server daemon, this model stores the state in files on the server. This can be simpler to set up, but all server processes must run on the one machine.

  • branching-server

    The branching-server model stores session state on the server in the same way as the session-server model, but uses hidden HTML fields to track users, and retains multiple versions of the state. This provides more flexibility when supporting users who use the browser “back” button or who duplicate their sessions, at the cost of more server-side storage.

There are 12 combinations of page and context model, although not all combinations are supported :- it is not possible to combine the random page model with the hidden-field or branching-server context models as these context models require a hidden form field to be sent via the client to maintain state, and this does not always happen with random access applications.

Choosing the appropriate class is made easier by the get_app_classes(page_model, context_model) function. Given the names of a page model and context model, this returns a 2-tuple containing a pre-packaged Application class and a matching Context class. These can be instantiated directly, or subclassed to add further functionality:

import albatross

appcls, ctxcls = albatross.get_app_classes('simple', 'hidden-field')

class Context(ctxcls):

    def __init__(self, app):
        ctxcls.__init__(self, app)

class Application(appcls):

    def create_context(self):
        return Context(self)

app = Application()
.build/figures/AlbatrossObjects.*

Albatross Classes

The SimpleContext Execution Context

The SimpleContext class is provided for applications which only make use of the Albatross template functionality. If you look at the implementation of the class you will note that it is constructed from a number of mixin classes. Each of these classes implements some of the functionality required for interpreting Albatross templates.

Diagrammatically the SimpleContext class looks like this:

.build/figures/simplecontext.*

The SimpleContext class

By implementing the execution context semantics in a collection of mixin classes Albatross allows you to change semantics by substituting mixins which implement the same interface. This is very useful when using the Albatross application objects.

NamespaceMixin This mixin provides a local namespace for evaluating the expressions embedded in the expr tag attributes. Application code places values into the locals member to make them available for display by the template files.

You will probably always use this mixin in your execution context.

ExecuteMixin This mixin provides a sort of virtual machine which is required by the template file interpreter. It maintains a macro argument stack for expanding macros, and it is used to accumulate HTML produced by template execution.

You will probably always use this mixin in your execution context.

ResourceMixin This mixin provides a registry of template resources which only need to be defined once. Specifically the class provides a dictionary of Python classes which implement template file tags, a dictionary of template macros, and a dictionary of template lookup tables.

If you are using Albatross application functionality, you will almost certainly use this mixin in your application class, not the execution context.

TemplateLoaderMixin This mixin is a very simple template file loader. You will almost certainly use the CachingTemplateLoaderMixin in your application object instead of this mixin when you use the Albatross application objects.

StubRecorderMixin Albatross provides special versions of the standard HTML <input>, <select>, and <form> tags. As these tags are converted to HTML they report back to the execution context. Applications which do not need to record the contents of each form can use this mixin to ignore the form record.

StubSessionMixin

Albatross provides an application session. Applications which do not a session can use this mixin to disable session functionality.

Collectively these classes provide all of the functionality which is required to execute Albatross templates. The following table contains a list of all methods defined in the context.

Method Mixin
add_session_vars(*names)() StubSessionMixin
clear_active_select() ExecuteMixin
clear_locals() NamespaceMixin
del_session_vars(*names)() StubSessionMixin
discard_file_resources(filename)() ResourceMixin
encode_session() StubSessionMixin
eval_expr(expr)() NamespaceMixin
flush_content() ExecuteMixin
flush_html() ExecuteMixin
form_close() StubRecorderMixin
form_open() StubRecorderMixin
get_active_select() ExecuteMixin
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_macro_arg(name)() ExecuteMixin
get_tagclass(name)() ResourceMixin
get_value(name)() NamespaceMixin
has_value(name)() NamespaceMixin
has_values(*names)() NamespaceMixin
input_add(itype, name, value, return_list)() StubRecorderMixin
load_session() StubSessionMixin
load_template(name)() TemplateLoaderMixin
load_template_once(name)() TemplateLoaderMixin
make_alias(name)() NamespaceMixin
merge_request() StubRecorderMixin
merge_vars(*vars)() NamespaceMixin
namespace_path(name)() NamespaceMixin
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_namespace() NamespaceMixin
push_content_trap() ExecuteMixin
push_macro_args(args, defaults)() ExecuteMixin
push_namespace(name)() NamespaceMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session() StubSessionMixin
reset_content() ExecuteMixin
reset_namespace() NamespaceMixin
save_session() StubSessionMixin
send_content(data)() ExecuteMixin
set_active_select(select, value)() ExecuteMixin
set_globals(dict)() NamespaceMixin
set_save_session(flag)() StubSessionMixin
set_value(name, value)() NamespaceMixin
should_save_session() StubSessionMixin
write_content(data)() ExecuteMixin
write_unsafe(data)() ExecuteMixin

Looking inside the context module you will notice some mixin classes which provide alternatives for some of the context functionality. The CachingTemplateLoaderMixin class can be used to replace the TemplateLoaderMixin. Likewise the NameRecorderMixin class is a drop-in replacement for the StubRecorderMixin class. These alternatives are used by some of the prepackaged application objects.

Although all of the template file examples in the Templates User Guide used the SimpleContext class as the execution context, you are much more likely to use something derived from the AppContext class defined in the app module. Since Albatross creates a new execution context to process each browser request, it makes sense to manage tag classes, macros, and lookup tables somewhere other than in the execution context.

The AppContext Base Class

All execution contexts used by Albatross application classes are derived from the AppContext class. The class acts as a proxy and redirects all ResourceMixin and TemplateLoader class methods to the application object. This allows the application to cache resources so that they do not need to be defined for every request.

The class places very few assumptions about how you wish to structure and deploy your application and is suitable as a base class for all application execution context classes.

.build/figures/appcontext.*

The AppContext class

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

Method Mixin
absolute_base_url() AppContext
add_header(name, value)() ResponseMixin
base_url() AppContext
clear_active_select() ExecuteMixin
clear_locals() AppContext
current_url() AppContext
del_header(name)() ResponseMixin
eval_expr(expr)() NamespaceMixin
flush_content() ExecuteMixin
flush_html() ExecuteMixin
get_active_select() ExecuteMixin
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
load_template(name)() AppContext
load_template_once(name)() AppContext
log(msg)() AppContext
make_alias(name)() NamespaceMixin
merge_vars(*vars)() NamespaceMixin
namespace_path(name)() NamespaceMixin
parsed_request_uri() AppContext
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_namespace() NamespaceMixin
pop_page(target_page)() AppContext
push_content_trap() ExecuteMixin
push_macro_args(args, defaults)() ExecuteMixin
push_namespace(name)() NamespaceMixin
push_page(name, *args)() AppContext
redirect(loc)() AppContext
redirect_url(loc)() AppContext
register_lookup(name, lookup)() AppContext
register_macro(name, macro)() AppContext
req_equals(name)() AppContext
reset_content() ExecuteMixin
reset_namespace() NamespaceMixin
run_template(name)() AppContext
run_template_once(name)() AppContext
send_content(data)() ResponseMixin
send_redirect(loc)() ResponseMixin
set_active_select(select, value)() ExecuteMixin
set_globals(dict)() NamespaceMixin
set_header(name, value)() ResponseMixin
set_page(name, *args)() AppContext
set_request(req)() AppContext
set_value(name, value)() NamespaceMixin
write_content(data)() ExecuteMixin
write_headers() ResponseMixin
write_unsafe(data)() ExecuteMixin

There are a number of new methods and attributes introduced by the class.

AppContext.__init__(app)

When you inherit from the AppContext class you must call this constructor.

The app argument specifies the application object. This is saved in the app member.

AppContext.app

Stores the app argument to the constructor.

AppContext.get_macro(name)

Returns the result of the get_macro() method of the application in the app member.

AppContext.register_macro(name, macro)

Returns the result of the register_macro() method of the application in the app member.

AppContext.get_lookup(name)

Returns the result of the get_lookup() method of the application in the app member.

AppContext.register_lookup(name, lookup)

Returns the result of the register_lookup() method of the application in the app member.

AppContext.get_tagclass(name)

Returns the result of the get_tagclass() method of the application in the app member.

AppContext.load_template(name)

Returns the result of the load_template() method of the application in the app member.

AppContext.load_template_once(name)

Returns the result of the load_template_once() method of the application in the app member.

AppContext.run_template(name)

Calls the application load_template() method to load the template specified in the name argument and sets the execution context global namespace to the globals of the function which called this method. The template to_html() method is then called to execute the template.

AppContext.run_template_once(name)

Calls the application load_template_once() method. If the template specified in the name argument is loaded or reloaded the method sets the execution context global namespace to the globals of the function which called this method, then the template to_html() method is then called to execute the template.

AppContext.clear_locals()

Overrides the NamespaceMixin clear_locals() method to retain the __page__ local namespace value.

AppContext.set_page(name[, ...])

Sets the current application page to that specified in the name argument. If changing pages and there is a current page defined then before changing pages the page_leave() function/method will be called for the current page. The locals.__page__ member is then set to name and the new page is loaded. Any addition arguments passed to the method will be passed to the page_enter() function/method code which is associated with the new page.

Refer to PageMixin Classes for an explanation of page functions/methods.

AppContext.push_page(name[, ...])

Pushes an application page onto the page stack. The current page can be returned to by calling the pop_page() method. The page_leave() function/method of the current page is not called. The new page is loaded and it’s page_enter() function/method is called. Any additional arguments given will be passed to the page_enter() function/method associated with the new page.

AppContext.pop_page()

Pops the current page from the page stack and returns to the page that was current when the push_page() method was called. The page_leave() function/method of the current page is called prior to loading the original page. The page_enter() function/method of the original page is not called.

AppContext.set_request(req)

Saves the browser request specified in the req argument as the request.

AppContext.req_equals(name)

Returns whether or not the browser request contains a non-empty field with a name which matches the name argument.

AppContext.base_url()

Returns the result of the application base_url() method.

AppContext.current_url()

Returns the path component (see the standard urlparse module) of the URI used to request the current page.

AppContext.absolute_base_url()

Returns the base_url parameter to the application constructor transformed into an absolute URL.

AppContext.redirect_url(loc)

Returns an absolute URL for the application page identifier specified in the loc parameter.

AppContext.redirect(loc)

Raises a Redirect exception requesting a redirect to the location in the loc parameter from the application run() method.

If the loc parameter contains either a scheme or netloc (from the standard urlparse module), or begins with a “/” then is it used without modification for the Redirect exception. Other forms of loc are assumed to be page identifiers and are passed to redirect_url() before being raised as a Redirect exception.

Context classes:

The SimpleAppContext Class

The SimpleAppContext class is intended to be used for applications which store state at the browser in hidden HTML fields. An inheritance diagram illustrates the relationship to the SimpleContext class described above.

.build/figures/simpleappcontext.*

The SimpleAppContext class

The methods available in SimpleAppContext 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_active_select() ExecuteMixin
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() HiddenFieldSessionMixin
eval_expr(expr)() NamespaceMixin
flush_content() ExecuteMixin
flush_html() ExecuteMixin
form_close() SimpleAppContext
form_open() NameRecorderMixin
get_active_select() ExecuteMixin
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() HiddenFieldSessionMixin
load_template(name)() AppContext
load_template_once(name)() AppContext
log(msg)() AppContext
make_alias(name)() NamespaceMixin
merge_request() NameRecorderMixin
merge_vars(*vars)() NamespaceMixin
namespace_path(name)() NamespaceMixin
parsed_request_uri() AppContext
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_namespace() NamespaceMixin
pop_page(target_page)() AppContext
push_content_trap() ExecuteMixin
push_macro_args(args, defaults)() ExecuteMixin
push_namespace(name)() NamespaceMixin
push_page(name, *args)() AppContext
redirect(loc)() AppContext
redirect_url(loc)() AppContext
register_lookup(name, lookup)() AppContext
register_macro(name, macro)() AppContext
remove_session() SessionBase
req_equals(name)() AppContext
reset_content() ExecuteMixin
reset_namespace() NamespaceMixin
run_template(name)() AppContext
run_template_once(name)() AppContext
save_session() HiddenFieldSessionMixin
send_content(data)() ResponseMixin
send_redirect(loc)() ResponseMixin
session_vars() SessionBase
set_active_select(select, value)() ExecuteMixin
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
write_content(data)() ExecuteMixin
write_headers() ResponseMixin
write_unsafe(data)() ExecuteMixin

The SimpleAppContext class provides the following functionality to your application.

  • Application state is stored inside hidden fields in the HTML.

    This function is performed by the HiddenFieldSessionMixin mixin class which places a hidden field named __albstate__ inside each HTML form constructed using <al-form> tags. The session data is pickled, compressed, then base64 encoded. No encryption is performed, so this is not suitable for storing sensitive data.

    If you refer back to the Albatross application processing sequence described in the Albatross Application Model section, you will note where the session is loaded into and saved from the context. These steps correspond to the load_session() and save_session() methods of the execution context respectively.

    In the HiddenFieldSessionMixin class, the load_session() method retrieves the encoded session data from the __albstate__ field in the browser request. The save_session() method does not do anything because the session has already been saved into each form produced in the HTML output.

  • All input fields in an HTML form which are left empty by the browser will be set to None when the request is merged into the local namespace.

    The NameRecorderMixin mixin class encodes the names of all <al-input> fields in the form inside a hidden field named __albform__.

    Any input field which is left empty in the browser when the form is submitted will not exist in the browser request to the server. When the toolkit merges the browser request into the application context, the __albform__ field is used to detect the fields missing from the browser request.

The methods implemented in the SimpleAppContext class are:

SimpleAppContext.__init__(app)

When you inherit from the SimpleAppContext class you must call this constructor.

The app argument is passed to the AppContext constructor.

SimpleAppContext.form_close()

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

The SessionAppContext Class

The SessionAppContext class is intended to be used for applications which store state at the server. An inheritance diagram illustrates the relationship to the SimpleAppContext class described above.

.build/figures/sessionappcontext.*

The SessionAppContext class

The methods available in SessionAppContext 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_active_select() ExecuteMixin
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() NameRecorderMixin
form_open() NameRecorderMixin
get_active_select() ExecuteMixin
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() SessionServerContextMixin
load_template(name)() AppContext
load_template_once(name)() AppContext
log(msg)() AppContext
make_alias(name)() NamespaceMixin
merge_request() NameRecorderMixin
merge_vars(*vars)() NamespaceMixin
namespace_path(name)() NamespaceMixin
new_session() SessionServerContextMixin
parsed_request_uri() AppContext
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_namespace() NamespaceMixin
pop_page(target_page)() AppContext
push_content_trap() ExecuteMixin
push_macro_args(args, defaults)() ExecuteMixin
push_namespace(name)() NamespaceMixin
push_page(name, *args)() AppContext
redirect(loc)() AppContext
redirect_url(loc)() AppContext
register_lookup(name, lookup)() AppContext
register_macro(name, macro)() AppContext
remove_session() SessionServerContextMixin
req_equals(name)() AppContext
reset_content() ExecuteMixin
reset_namespace() NamespaceMixin
run_template(name)() AppContext
run_template_once(name)() AppContext
save_session() SessionServerContextMixin
send_content(data)() ResponseMixin
send_redirect(loc)() ResponseMixin
sesid() SessionServerContextMixin
session_vars() SessionBase
set_active_select(select, value)() ExecuteMixin
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
write_content(data)() ExecuteMixin
write_headers() ResponseMixin
write_unsafe(data)() ExecuteMixin

Externally the execution context is almost identical to that of the SimpleAppContext class. Instead of saving session data in hidden HTML fields, session data is loaded and saved via a session server which is managed by the application.

The class defines a number of extra methods.

SessionAppContext.__init__(app)

When you inherit from the SessionAppContext class you must call this constructor.

The app argument is passed to the AppContext constructor.

The SessionFileAppContext Class

The SessionFileAppContext class is intended to be used for applications which store state at the server. An inheritance diagram illustrates the relationship to the SimpleAppContext class described above.

.build/figures/sessionfileappcontext.*

The SessionFileAppContext class

The methods available in SessionFileAppContext 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_active_select() ExecuteMixin
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() NameRecorderMixin
form_open() NameRecorderMixin
get_active_select() ExecuteMixin
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() SessionFileContextMixin
load_template(name)() AppContext
load_template_once(name)() AppContext
log(msg)() AppContext
make_alias(name)() NamespaceMixin
merge_request() NameRecorderMixin
merge_vars(*vars)() NamespaceMixin
namespace_path(name)() NamespaceMixin
new_session() SessionFileContextMixin
parsed_request_uri() AppContext
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_namespace() NamespaceMixin
pop_page(target_page)() AppContext
push_content_trap() ExecuteMixin
push_macro_args(args, defaults)() ExecuteMixin
push_namespace(name)() NamespaceMixin
push_page(name, *args)() AppContext
redirect(loc)() AppContext
redirect_url(loc)() AppContext
register_lookup(name, lookup)() AppContext
register_macro(name, macro)() AppContext
remove_session() SessionFileContextMixin
req_equals(name)() AppContext
reset_content() ExecuteMixin
reset_namespace() NamespaceMixin
run_template(name)() AppContext
run_template_once(name)() AppContext
save_session() SessionFileContextMixin
send_content(data)() ResponseMixin
send_redirect(loc)() ResponseMixin
sesid() SessionFileContextMixin
session_vars() SessionBase
set_active_select(select, value)() ExecuteMixin
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
write_content(data)() ExecuteMixin
write_headers() ResponseMixin
write_unsafe(data)() ExecuteMixin

Externally the execution context is almost identical to that of the SimpleAppContext class. Instead of saving session data in hidden HTML fields, session data is loaded and saved to the servers local file system, which is managed by the application.

The class defines a number of extra methods.

SessionFileAppContext.__init__(app)

When you inherit from the SessionFileAppContext class you must call this constructor.

The app argument is passed to the AppContext constructor.

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.

.build/figures/branchingsessioncontext.*

The BranchingSessionContext class

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_active_select() ExecuteMixin
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_active_select() ExecuteMixin
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
log(msg)() AppContext
make_alias(name)() NamespaceMixin
merge_request() NameRecorderMixin
merge_vars(*vars)() NamespaceMixin
namespace_path(name)() NamespaceMixin
parsed_request_uri() AppContext
pop_content_trap() ExecuteMixin
pop_macro_args() ExecuteMixin
pop_namespace() NamespaceMixin
pop_page(target_page)() AppContext
push_content_trap() ExecuteMixin
push_macro_args(args, defaults)() ExecuteMixin
push_namespace(name)() NamespaceMixin
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
reset_namespace() NamespaceMixin
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_active_select(select, value)() ExecuteMixin
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
write_unsafe(data)() ExecuteMixin

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:

BranchingSessionContext.__init__(app)

When you inherit from the BranchingSessionContext class you must call this constructor.

The app argument is passed to the AppContext constructor.

BranchingSessionContext.form_close()

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

The Application Base Class

The Application class is the base class for all Albatross application objects.

The class inherits from the ResourceMixin class to allow all application resources to be loaded once and used for every browser request. The AppContext class directs all resource related execution context method here.

.build/figures/application.*

The Application class

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

Method Mixin
base_url() Application
discard_file_resources(filename)() ResourceMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
load_session(ctx)() Application
merge_request(ctx)() Application
pickle_sign(text)() Application
pickle_unsign(text)() Application
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
set_logger(logger)() Application
template_traceback(tb)() Application
validate_request(ctx)() Application

The Application class introduces a number of new methods.

Application.__init__(base_url)

When you inherit from the Application class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags.

Application.base_url()

Returns the base_url argument which was passed to the constructor.

Application.run(req)

Implements the standard application run sequence as described in the Albatross Application Model section. The browser request passed as the req argument is attached to the execution context as soon as the context has been created.

If an exception is caught then the handle_exception() method is called passing the req argument.

Application.format_exception()

Retrieves the current exception from sys.exc_info() then formats and returns the standard Python traceback and a template interpreter traceback.

Application.handle_exception(ctx, req)

This implements the default exception handling for applications. The req argument is the browser request which was passed to the run() method.

The method calls the format_exception() method to construct a standard Python traceback and a template traceback. A temporary execution context is then created, the Python traceback is saved in the locals.python_exc value, and the template traceback in the locals.html_exc value.

The method then tries to load the 'uncaught_exception.html' template file and execute it with the temporary execution context. This gives you the ability to control the presentation and reporting of exceptions.

If any exceptions are raised during the execution of 'uncaught_exception.html' the method writes both formatted exceptions as a <pre> formatted browser response.

Application.template_traceback(tb)

Generates a template interpreter traceback from the Python stack trace in the tb argument.

Application.load_session(ctx)

Calls the load_session() method of the execution context in the ctx argument.

Application.save_session(ctx)

Calls the save_session() method of the execution context in the ctx argument.

Application.remove_session(ctx)

Calls the remove_session() method of the execution context in the ctx argument.

Application.validate_request(ctx)

Returns TRUE.

You should override this method in your application object if you need to validate browser requests before processing them. Returning False will prevent the browser request being merged into the local namespace and the page_process logic will not be called (see also the description of the Albatross Application Model in Albatross Application Model).

Application.pickle_sign(text)

Returns an empty string to prevent insecure pickles being sent to the browser. This is overridden in the PickleSignMixin class.

Application.pickle_unsign(text)

Returns an empty string to prevent insecure pickles being accepted from the browser. This is overridden in the PickleSignMixin class.

Application.merge_request(ctx)

Calls the merge_request() method of the execution context.

Application Classes:

The SimpleApp Class

The SimpleApp class is intended for use in monolithic applications (page objects instead of page modules). An inheritance diagram illustrates the relationship to the SimpleAppContext class described above.

.build/figures/simpleapp.*

The SimpleApp class

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

Method Mixin
base_url() Application
create_context() SimpleApp
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() PageObjectMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageObjectMixin
load_page(ctx)() PageObjectMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
page_enter(ctx, args)() PageObjectMixin
page_leave(ctx)() PageObjectMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() PageObjectMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_page(name, obj)() PageObjectMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
set_logger(logger)() Application
start_page() PageObjectMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The SimpleApp class defines the following methods:

SimpleApp.__init__(base_url, template_path, start_page, secret)

When you inherit from the SimpleApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The template_path defines the root directory where template files are loaded from. The start_page identifies the first page that will be served up in a new browser session. The secret argument is used to sign all pickles sent to the browser.

SimpleApp.create_context()

Returns a new instance of the SimpleAppContext class.

The SimpleSessionApp Class

The SimpleSessionApp class is intended for use in monolithic applications (page objects instead of page modules). Session state is stored at the server.

.build/figures/simplesessapp.*

The SimpleSessionApp class

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

Method Mixin
base_url() Application
create_context() SimpleSessionApp
del_session(sesid)() SessionServerAppMixin
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() PageObjectMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_session(sesid)() SessionServerAppMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageObjectMixin
load_page(ctx)() PageObjectMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
new_session() SessionServerAppMixin
page_enter(ctx, args)() PageObjectMixin
page_leave(ctx)() PageObjectMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() PageObjectMixin
put_session(sesid, text)() SessionServerAppMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_page(name, obj)() PageObjectMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
ses_age() SessionServerAppMixin
ses_appid() SessionServerAppMixin
set_logger(logger)() Application
start_page() PageObjectMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The SimpleSessionApp class defines the following methods:

SimpleSessionApp.__init__(base_url, template_path, start_page, secret, session_appid [, session_server ``= 'localhost'``] [, server_port ``= 34343``] [, session_age ``= 1800``])

When you inherit from the SimpleSessionApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The template_path defines the root directory where template files are loaded from. The start_page identifies the first page that will be served up in a new browser session. The secret argument is used to sign all pickles sent to the browser.

The session_appid argument identifies the session application at the session server. Multiple applications can share sessions by using the same identifier here. The session_server argument defines the host where the session server is running, it defaults to localhost. The server_port defines the session server port, it defaults to 34343. The session_age argument defines the number of seconds that an idle session will be kept, it defaults to 1800.

SimpleSessionApp.create_context()

Returns a new instance of the SessionAppContext class.

The SimpleSessionFileApp Class

The SimpleSessionFileApp class is intended for use in monolithic applications (page objects instead of page modules). Session state is stored in the file system at the server.

.build/figures/simplesessfileapp.*

The SimpleSessionFileApp class

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

Method Mixin
base_url() Application
create_context() SimpleSessionFileApp
del_session(sesid)() SessionFileAppMixin
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() PageObjectMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_session(sesid)() SessionFileAppMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageObjectMixin
load_page(ctx)() PageObjectMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
new_session() SessionFileAppMixin
page_enter(ctx, args)() PageObjectMixin
page_leave(ctx)() PageObjectMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() PageObjectMixin
put_session(sesid, text)() SessionFileAppMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_page(name, obj)() PageObjectMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
ses_age() SessionFileAppMixin
ses_appid() SessionFileAppMixin
set_logger(logger)() Application
start_page() PageObjectMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The SimpleSessionFileApp class defines the following methods:

SimpleSessionFileApp.__init__(base_url, template_path, start_page, secret, session_appid, session_dir)

When you inherit from the SimpleSessionFileApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The template_path defines the root directory where template files are loaded from. The start_page identifies the first page that will be served up in a new browser session. The secret argument is used to sign all pickles sent to the browser.

The session_appid argument identifies the session application in the browser cookie. Multiple applications can share sessions by using the same identifier here. The session_dir argument defines the directory in which the application will store session files.

SimpleSessionFileApp.create_context()

Returns a new instance of the SessionFileAppContext class.

The ModularApp Class

The ModularApp class is intended for use in applications which define page code in a collection of Python modules.

.build/figures/modularapp.*

The ModularApp class

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

Method Mixin
base_url() Application
create_context() ModularApp
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() PageModuleMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageModuleMixin
load_page(ctx)() PageModuleMixin
load_page_module(ctx, name)() PageModuleMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
module_path() PageModuleMixin
page_enter(ctx, args)() PageModuleMixin
page_leave(ctx)() PageModuleMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() PageModuleMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
set_logger(logger)() Application
start_page() PageModuleMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The ModularApp class defines the following methods:

ModularApp.__init__(base_url, module_path, template_path, start_page, secret)

When you inherit from the ModularApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The module_path argument defines the root directory where page modules are loaded from. The template_path argument defines the root directory where template files are loaded from. The start_page identifies the first page that will be served up in a new browser session. The secret argument is used to sign all pickles sent to the browser.

ModularApp.create_context()

Returns a new instance of the SimpleAppContext class.

The ModularSessionApp Class

The ModularSessionApp class is intended for use in applications which define page code in a collection of Python modules. Session state is stored at the server.

.build/figures/modularsessapp.*

The ModularSessionApp class

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

Method Mixin
base_url() Application
create_context() ModularSessionApp
del_session(sesid)() SessionServerAppMixin
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() PageModuleMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_session(sesid)() SessionServerAppMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageModuleMixin
load_page(ctx)() PageModuleMixin
load_page_module(ctx, name)() PageModuleMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
module_path() PageModuleMixin
new_session() SessionServerAppMixin
page_enter(ctx, args)() PageModuleMixin
page_leave(ctx)() PageModuleMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() PageModuleMixin
put_session(sesid, text)() SessionServerAppMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
ses_age() SessionServerAppMixin
ses_appid() SessionServerAppMixin
set_logger(logger)() Application
start_page() PageModuleMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The ModularSessionApp class defines the following methods:

ModularSessionApp.__init__(base_url, module_path, template_path, start_page, secret, session_appid [, session_server ``= 'localhost'``] [, server_port ``= 34343``] [, session_age ``= 1800``])

When you inherit from the ModularSessionApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The module_path argument defines the root directory where page modules are loaded from. The template_path argument defines the root directory where template files are loaded from. The start_page identifies the first page that will be served up in a new browser session. The secret argument is used to sign all pickles sent to the browser.

The session_appid argument identifies the session application at the session server. Multiple applications can share sessions by using the same identifier here. The session_server argument defines the host where the session server is running, it defaults to localhost. The server_port defines the session server port, it defaults to 34343. The session_age argument defines the number of seconds that an idle session will be kept, it defaults to 1800.

ModularSessionApp.create_context()

Returns a new instance of the SessionAppContext class.

The ModularSessionFileApp Class

The ModularSessionFileApp class is intended for use in applications which define page code in a collection of Python modules. Session state is stored in the file system at the server.

.build/figures/modularsessfileapp.*

The ModularSessionFileApp class

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

Method Mixin
base_url() Application
create_context() ModularSessionFileApp
del_session(sesid)() SessionFileAppMixin
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() PageModuleMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_session(sesid)() SessionFileAppMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageModuleMixin
load_page(ctx)() PageModuleMixin
load_page_module(ctx, name)() PageModuleMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
module_path() PageModuleMixin
new_session() SessionFileAppMixin
page_enter(ctx, args)() PageModuleMixin
page_leave(ctx)() PageModuleMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() PageModuleMixin
put_session(sesid, text)() SessionFileAppMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
ses_age() SessionFileAppMixin
ses_appid() SessionFileAppMixin
set_logger(logger)() Application
start_page() PageModuleMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The ModularSessionFileApp class defines the following methods:

ModularSessionFileApp.__init__(base_url, module_path, template_path, start_page, secret, session_appid, session_dir)

When you inherit from the ModularSessionFileApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The module_path argument defines the root directory where page modules are loaded from. The template_path argument defines the root directory where template files are loaded from. The start_page identifies the first page that will be served up in a new browser session. The secret argument is used to sign all pickles sent to the browser.

The session_appid argument identifies the session application in the browser cookie. Multiple applications can share sessions by using the same identifier here. The session_dir argument defines the directory in which the application will store session files.

ModularSessionFileApp.create_context()

Returns a new instance of the SessionFileAppContext class.

The RandomModularApp Class

The RandomModularApp class is intended for use in applications which define page code in a collection of Python modules which are randomly accessed via the URI in the browser request.

.build/figures/randmodapp.*

The RandomModularApp class

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

Method Mixin
base_url() Application
create_context() RandomModularApp
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() RandomPageModuleMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_page_from_uri(ctx, uri)() RandomPageModuleMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageModuleMixin
load_badurl_template(ctx)() RandomPageModuleMixin
load_page(ctx)() RandomPageModuleMixin
load_page_module(ctx, name)() PageModuleMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
module_path() PageModuleMixin
page_enter(ctx)() RandomPageModuleMixin
page_leave(ctx)() PageModuleMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() RandomPageModuleMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
set_logger(logger)() Application
start_page() PageModuleMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The RandomModularApp class defines the following methods:

RandomModularApp.__init__(base_url, page_path, start_page, secret)

When you inherit from the RandomModularApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The page_path argument defines the root directory where page modules and template files are loaded from. The start_page identifies the page that will be served up when a page identifier cannot be determined from the URI in the browser request. The secret argument is used to sign all pickles sent to the browser.

RandomModularApp.create_context()

Returns a new instance of the SimpleAppContext class.

The RandomModularSessionApp Class

The RandomModularSessionApp class is intended for use in applications which define page code in a collection of Python modules which are randomly accessed via the URI in the browser request. Session state is stored at the server.

.build/figures/randmodsessapp.*

The RandomModularSessionApp class

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

Method Mixin
base_url() Application
create_context() RandomModularSessionApp
del_session(sesid)() SessionServerAppMixin
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() RandomPageModuleMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_page_from_uri(ctx, uri)() RandomPageModuleMixin
get_session(sesid)() SessionServerAppMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageModuleMixin
load_badurl_template(ctx)() RandomPageModuleMixin
load_page(ctx)() RandomPageModuleMixin
load_page_module(ctx, name)() PageModuleMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
module_path() PageModuleMixin
new_session() SessionServerAppMixin
page_enter(ctx)() RandomPageModuleMixin
page_leave(ctx)() PageModuleMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() RandomPageModuleMixin
put_session(sesid, text)() SessionServerAppMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
ses_age() SessionServerAppMixin
ses_appid() SessionServerAppMixin
set_logger(logger)() Application
start_page() PageModuleMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The RandomModularSessionApp class defines the following methods:

RandomModularSessionApp.__init__(base_url, page_path, start_page, secret, session_appid [, session_server ``= 'localhost'``] [, server_port ``= 34343``] [, session_age ``= 1800``])

When you inherit from the RandomModularSessionApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The page_path argument defines the root directory where page modules and template files are loaded from. The start_page identifies the page that will be served up when a page identifier cannot be determined from the URI in the browser request. The secret argument is used to sign all pickles sent to the browser.

The session_appid argument identifies the session application at the session server. Multiple applications can share sessions by using the same identifier here. The session_server argument defines the host where the session server is running, it defaults to localhost. The server_port defines the session server port, it defaults to 34343. The session_age argument defines the number of seconds that an idle session will be kept, it defaults to 1800.

RandomModularSessionApp.create_context()

Returns a new instance of the SessionAppContext class.

The RandomModularSessionFileApp Class

The RandomModularSessionFileApp class is intended for use in applications which define page code in a collection of Python modules which are randomly accessed via the URI in the browser request. Session state is stored in the file system at the server.

.build/figures/randmodsessfileapp.*

The RandomModularSessionFileApp class

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

Method Mixin
base_url() Application
create_context() RandomModularSessionFileApp
del_session(sesid)() SessionFileAppMixin
discard_file_resources(filename)() ResourceMixin
display_response(ctx)() RandomPageModuleMixin
format_exception() Application
get_lookup(name)() ResourceMixin
get_macro(name)() ResourceMixin
get_page_from_uri(ctx, uri)() RandomPageModuleMixin
get_session(sesid)() SessionFileAppMixin
get_tagclass(name)() ResourceMixin
handle_exception(ctx, req)() Application
handle_session_expired(ctx, req)() Application
is_page_module(name)() PageModuleMixin
load_badurl_template(ctx)() RandomPageModuleMixin
load_page(ctx)() RandomPageModuleMixin
load_page_module(ctx, name)() PageModuleMixin
load_session(ctx)() Application
load_template(name)() CachingTemplateLoaderMixin
load_template_once(name)() CachingTemplateLoaderMixin
merge_request(ctx)() Application
module_path() PageModuleMixin
new_session() SessionFileAppMixin
page_enter(ctx)() RandomPageModuleMixin
page_leave(ctx)() PageModuleMixin
pickle_sign(text)() PickleSignMixin
pickle_unsign(text)() PickleSignMixin
process_request(ctx)() RandomPageModuleMixin
put_session(sesid, text)() SessionFileAppMixin
register_lookup(name, lookup)() ResourceMixin
register_macro(name, macro)() ResourceMixin
register_tagclasses(*tags)() ResourceMixin
remove_session(ctx)() Application
run(req)() Application
save_session(ctx)() Application
ses_age() SessionFileAppMixin
ses_appid() SessionFileAppMixin
set_logger(logger)() Application
start_page() PageModuleMixin
template_traceback(tb)() Application
validate_request(ctx)() Application

The RandomModularSessionFileApp class defines the following methods:

RandomModularSessionFileApp.__init__(base_url, page_path, start_page, secret, session_appid, session_dir)

When you inherit from the RandomModularSessionFileApp class you must call this constructor.

The base_url argument is used as the base for URLs produced by the <al-a> and <al-form> tags. The page_path argument defines the root directory where page modules and template files are loaded from. The start_page identifies the page that will be served up when a page identifier cannot be determined from the URI in the browser request. The secret argument is used to sign all pickles sent to the browser.

The session_appid argument identifies the session application at the session server. Multiple applications can share sessions by using the same identifier here. The session_dir argument defines the directory in which the application will store session files.

RandomModularSessionFileApp.create_context()

Returns a new instance of the SessionFileAppContext class.