Skipole WSGI generator.

Topics:

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

Tests at PythonAnywhere:

Widgets

Development at Bitbucket:

Skipole Project Documentation Downloads

Your project Python code

The projectfiles directory containing project myproj should have been created as previously described. Within it you will be developing ...projectfiles/myproj/code/myproj.py

myproj.py will already be set up to do most of the following work, but in summary, it needs to import the WSGIApplication class.

Creating an instance of this WSGISpplication object creates an 'application' which can be used by any WSGI web server.

An instance is created within myproj.py with the lines:


    from skipole import WSGIApplication
    application = WSGIApplication(project='myproj',
                                  projectfiles=PROJECTFILES,
                                  proj_data={},
                                  start_call=start_call,
                                  submit_data=submit_data,
                                  end_call=end_call,
                                  url="/")

Where 'PROJECTFILES' is the path to your projectfiles directory - this informs the object where the project JSON files can be found.

start_call, submit_data and end_call are three functions that you will provide. Minimum versions are available in myproj.py which you will develop further. They are called during the progress of a call:

start_call(called_ident, skicall)

start_call is called when the server initially receives an incoming call.

submit_data(skicall)

submit_data is called by Responder pages.

end_call(page_ident, page_type, skicall)

end_call is called after any Responders have handled the call and prior to returning the page.

These functions can in turn call on any further modules you wish to include within the package - hence you can access your own databases and functionality.

You will notice the framework passes the skicall object to your functions which contains a good deal of information you will need, more about it is given here:skicall

In particular your functions will modify the skicall.page_data attribute which will set field values in the page finally returned to the client. For further details:skicall.page_data

Before the application is ready, it needs to have the application from the 'skis' project added to it. Within myproj.py you will see this is done with:


    skis_code = os.path.join(PROJECTFILES, 'skis', 'code')
    if skis_code not in sys.path:
        sys.path.append(skis_code)
    import skis
    skis_application = skis.makeapp(PROJECTFILES)
    application.add_project(skis_application, url='/lib')

This 'skis' application serves javascript files used by the framework, so it is always needed.

Exceptions

Your myproj.py module also imports four exceptions which you can use in your functions:

from skipole import FailPage, GoTo, ValidateError, ServerError

Further information about the exceptions and their arguments can be found at:

FailPage(message = '', section='', widget='')

GoTo(target, clear_submitted=False, clear_page_data=False)

ValidateError(message = '', section='', widget='', status='400 Bad Request')

ServerError(message = '', section='', widget='', status='500 Internal Server Error', code=0)

Further information is available within the skiadmin pages, and the Documentation link to the left.