wuttaweb.views.batch

Base logic for Batch Master views

class wuttaweb.views.batch.BatchMasterView(request, context=None)[source]

Base class for all “batch master” views.

batch_handler

Reference to the batch handler for use with the view.

This is set when the view is first created, using return value from get_batch_handler().

delete_instance(batch)[source]

Delete the given batch instance.

This calls do_delete() on the batch_handler.

execute()[source]

View to execute the current batch.

Eventually this should show a progress indicator etc., but for now it simply calls do_execute() on the batch_handler and waits for it to complete, then redirects user back to the “view batch” page.

get_batch_handler()[source]

Must return the batch handler for use with this view.

There is no default logic; subclass must override.

get_fallback_templates(template)[source]

We override the default logic here, to prefer “batch” templates over the “master” templates.

So for instance the “view batch” page will by default use the /batch/view.mako template - which does inherit from /master/view.mako but adds extra features specific to batches.

get_row_grid_data(batch)[source]

Returns the base query for the batch rows data.

objectify(form, **kwargs)[source]

We override the default logic here, to invoke make_batch() on the batch handler - when creating. Parent/default logic is used when updating.

Parameters:

**kwargs – Additional kwargs will be passed as-is to the make_batch() call.

populate_thread(batch_uuid, progress=None)[source]

Thread target for populating new object with progress indicator.

When a new batch is created, and the batch handler says it should also be populated, then this thread is launched to do so outside of the main request/response cycle. Progress bar is then shown to the user until it completes.

This method mostly just calls do_populate() on the batch handler.

redirect_after_create(batch)[source]

If the new batch requires initial population, we launch a thread for that and show the “progress” page.

Otherwise this will do the normal thing of redirecting to the “view” page for the new batch.

render_to_response(template, context)[source]

We override the default logic here, to inject batch-related context for the view() template specifically. These values are used in the template file, /batch/view.mako.

  • batch - reference to the current batch

  • batch_handler reference to batch_handler

  • why_not_execute - text of reason (if any) not to execute batch

  • execution_described - HTML (rendered from markdown) describing batch execution