Skipole WSGI generator.

Topics:

Introduction Getting Started Your Code start_call submit_data end_call skicall skicall.page_data Serving wsgi

Development at GitHub:

github.com/bernie-skipole/skipole

skicall.page_data

Your 'start_call', 'submit_data' and 'end_call' functions are used to populate the attribute 'skicall.page_data' which is a dictionary. This dictionary contents are used to set the widget fields of the final template page returned.

The keys of page_data are of the form:

If a widget is in a section:

skicall.page_data[sectionalias,widgetname,fieldname] = value

If a widget is not in a section:

skicall.page_data[widgetname,fieldname] = value

This framework often refers to the key tuple (widgetname,fieldname) as a widgfield.

Most of the skicall.page_data fields will be of the above form, however there are keys which set certain parameters, optionally overriding parameters set when the page is created:

skicall.page_data[sectionalias, 'hide'] - Set True to hide the section

skicall.page_data[sectionalias, 'multiplier'] - A section can be displayed multiple times - this sets the number of times this section to be shown

skicall.page_data[sectionalias, 'multiplier_tag'] - Set the section tag containing each section when multiplied

skicall.page_data[sectionalias, 'section_class'] - Set CSS class on the section

skicall.page_data[sectionalias, 'show'] - Set False to remove the section

These literal string keys set page parameters:

skicall.page_data['add_jscript'] - Set to a string containing javascript code. This will be set within the pages automatically generated "$(document).ready(function(){})" and will be run when the page is loaded.

skicall.page_data['backcol'] - Set the 'HTML' tag background color

skicall.page_data['body_class'] - The CSS class of the 'BODY' tag

skicall.page_data['headers'] - Sets the returned page headers

skicall.page_data['ident_data'] - Set to a string, which will be returned as the 'skicall.ident_data' attribute if this page submits any data. The data is base64 encoded and added to hidden fields on each form and link widget.

skicall.page_data['lang'] - Set the language, such as 'en' in the page 'HTML' tag. This is independent of the skicall lang and language attributes, though it would generally be set the same as skicall.language.

skicall.page_data['last_scroll'] - Set True to display the page at its last scroll position

skicall.page_data['localStorage'] - A dictionary of string keys and values to set in the browser storage

skicall.page_data['sessionStorage'] - A dictionary of string keys and values to set in the browser storage

skicall.page_data['show_backcol'] - Set True to enable the 'HTML' tag background color

skicall.page_data['show_error'] - Error message to be shown on the page default error widget

skicall.page_data['status'] - Sets the returned page status

For File pages:

skicall.page_data['filepath'] - The path (relative to projectfiles) to the linked static file.

skicall.page_data['mimetype'] - The mime type of the file.

skicall.page_data['enable_cache'] - If True instructs the client to cache the file.

For SVG pages (dynamic created pages, not static files):

skicall.page_data['height'] - Set the height

skicall.page_data['width'] - Set the width

skicall.page_data['enable_cache'] - Enables client cache of this page.

For CSS pages (dynamic created pages, not static files):

skicall.page_data['@import'] - A string or a list

skicall.page_data['enable_cache'] - Enables client cache of this page.

For JSON pages:

Those Widgets which submit data, or link to another page, are generally set with the page to call, and an HTML template page is returned. However some widgets can request a JSON page (requires javascript to be enabled in the client browser).

In this case an alternative HTML page such as 'no_javascript' can be set in the HTML link field, which will be shown if the JSON call fails due to javascript being disabled.

When a JSON request is made - you would typically call a Responder which sets the skicall.page_data widgfield/values into the target page 'general_json'. This being an empty JSON file which is then populated with the dictionary.

On being received by the client the page widget fields will be updated, this will be quick, as a whole page is not sent, and looks very dynamic. Only certain widgfields are 'JSON enabled' and can be updated - this is shown in the widget documentation for each field.

As well as widgets, on setting up a Template Page you will see that the page can be set to make a JSON call at set intervals. Again this can be useful to continuously update required fields on the page.

As well as widgfields, some specific fields can be set and returned in the JSON response, which have a particular effect, these are:

skicall.page_data['ident_data'] - Set to a string, which will be returned as the 'skicall.ident_data' attribute with any submitted data.

skicall.page_data['ClearAllErrors'] - If True, any widget displaying an Error will be cleared.

skicall.page_data['localStorage'] - A dictionary of string keys and values to set in the browser storage

skicall.page_data['sessionStorage'] - A dictionary of string keys and values to set in the browser storage

skicall.page_data['interval'] - The interval time in seconds which the template page will request JSON updates. Use 0 to disable the requests.

skicall.page_data['IntervalTarget'] - The label or ident of the target requested, typically a Responder which sets the data into a JSON page which is then returned.

skicall.page_data['JSONtoHTML'] - A url, label or ident to divert to.

This causes the client to call this target url.

Similarly, the value 'CatchToHTML' can also be set.

skicall.page_data['CatchToHTML'] - A label or ident.

This CatchToHTML target (typically a Responder leading to an HTML template) is called if the widgets being updated by a JSON call causes a javascript error of some sort, maybe due to an action not supported by the client browser. In this situation, the javascript error will be caught, and the CatchToHTML page will be called instead. This could be used in conjunction with:

skicall.page_data['throw'] = "Any error message"

This causes a javascript exception to be thrown, and will cause the CatchToHTML page to be called, if one has been set. If CatchToHTML has not been set, then an alert box with the error message will be shown.