wuttaweb.progress

Progress Indicators

class wuttaweb.progress.SessionProgress(request, key, success_msg=None, success_url=None, error_url=None)[source]

Progress indicator which uses Beaker session storage to track current status.

This is a subclass of wuttjamaican.progress.ProgressBase.

A view callable can create one of these, and then pass it into progress_loop() or similar.

As the loop updates progress along the way, this indicator will update the Beaker session to match.

Separately then, the client side can send requests for the progress() view, to fetch current status out of the Beaker session.

Parameters:
  • request – Current request object.

  • key – Unique key for this progress indicator. Used to distinguish progress indicators in the Beaker session.

Note that in addition to update() and finish() this progres class has some extra attributes and methods:

success_msg

Optional message to display to the user (via session flash) when the operation completes successfully.

success_url

URL to which user should be redirected, once the operation completes.

error_url

URL to which user should be redirected, if the operation encounters an error. If not specified, will fall back to success_url.

handle_error(error, error_url=None)[source]

This should be called by the view code, within a try/catch block upon error.

The session storage will be updated to reflect details of the error. Next time client requests the progress status it will learn of the error and redirect the user.

Parameters:
  • errorException instance.

  • error_url – Optional redirect URL; if not specified error_url is used.

handle_success(success_msg=None, success_url=None)[source]

This should be called by the view code, when the long-running operation completes.

The session storage will be updated to reflect the completed status. Next time client requests the progress status it will discover it has completed, and redirect the user.

Parameters:
  • success_msg – Optional message to display to the user (via session flash) when the operation completes successfully. If not specified success_msg (or nothing) is used

  • success_url – Optional redirect URL; if not specified success_url is used.

wuttaweb.progress.get_basic_session(request, **kwargs)[source]

Create/get a “basic” Beaker session object.

wuttaweb.progress.get_progress_session(request, key, **kwargs)[source]

Create/get a Beaker session object, to be used for progress.