anise.features.ui_.web package

Submodules

anise.features.ui_.web.helpers module

Feature for helpers related to web-based user interfaces.

class anise.features.ui_.web.helpers.AniseWebApplication(**b)

Bases: anise.data.Yaji.yaji.app.Application

Parameters
  • parentid – Optional id of a parent Application, which e.g. can be redirected back to after exit.

  • returntoparent – If to return back to the parentid application after exit in the user’s browser.

  • show_browser_closed_notification – If to show a useful notification (including a way to close the application) after the browser was closed by the user and restarted.

  • stop_implicitly_when_browser_closed – If to consider the application as intendedly stopped when the user has closed the browser instead of opening a new one.

  • skip_shutdown_dialog – If not to show a ui-blocking ‘application stopped’ dialog on ui shutdown.

  • browser_hook_heartbeat_threshold – The time window within the backend excepts a heartbeat from the browser side before it tries to open a new browser window.

  • head1 – The 1st level header text.

  • head2 – The 2nd level header text.

  • icon – The window icon.

  • mainview_icon – The icon of the mainview header.

_do_answeruserfeedback(index, answer)
Parameters

index (int) –

_do_getprogresses(since)
Parameters

since (int) –

_execution_scopepart_added(_)
_get_userfeedback_web_answers(requestindex)
_send_userfeedback_web_request(request)
_shutdown()
onbrowserreopened()

Reacts on the fact that the browser was opened again. Override this method in custom subclasses or leave the default implementation.

oninitialize()

Initializes the application. Override this method in custom subclasses or leave the default implementation.

This is called during application startup, so later than __init__ (or never if the app does not start).

Note

You should just override __init__ instead if possible!

onopenbrowsererror()

Reacts on errors when opening the browser. Override this method in custom subclasses or leave the default implementation.

onopenbrowserinformationoutput(kind, message)

Reacts on information output (e.g. by printing it to stdout) while opening the browser. Override this method in custom subclasses or leave the default implementation.

Parameters
  • kind – The internal code of the message.

  • message – The message text.

onprocessrequesterror(request, error)

Reacts on process request errors, e.g. by logging. Override this method in custom subclasses or leave the default implementation.

Parameters
  • request – The path part of the request url.

  • error – The Exception.

start()

Starts the application.

Note

If your instance was already started and stopped, you have to create a new instance for another run.

stop()

Stops the application.

  • It requests the parent application’s returntakeover procedure in some situations (see later),

  • then invokes stopping the user interface (triggers _yj_stopui),

    • which on browser side leads to ‘uiShutdown’ and back redirection to parent application in some situations

  • then shuts down the http server.

    • so the _yj_stopui event might never actually arrive, depending on timings (not an actual problem).

A uiShutdown disables the user interface by triggering the OnUiShutdown event (but only one time; further calls are ignored). Application code can register custom handlers to this event, but it does at least this:

  • visually disables the user interface and shows a ‘shut down’ text if skip_shutdown_dialog==False (the default)

  • if it happened due to the user tried to close a PyHtmlView and show_browser_closed_notification==True (not the default): makes a ‘_yj_application_tryclosebrowser’ request, so PyHtmlView support can close the window or parent applications can take control back

The browser side also runs uiShutdown e.g. when

  • _yj_pullevent requests fail (assumption: the application code side has stopped), or

  • after a yaji.stop() was called (see later).

A uiShutdown does not stop stuff like event polling, and will leave yaji.isrunning==True! The browser side yaji.stop() does the following:

  • requests ‘_yj_application_stop’, which calls Application.stop() on application code side

    • when backend answered: running uiShutdown

    • with disabled user interface during the request if

      • skip_shutdown_dialog==False (the default) or

      • it was explicitly called this way

Browser side calls yaji.stop() e.g. in those situations:

  • custom application code on browser side triggered it for application exit

  • a ‘_yj_unhandled_client_error’ occurred and the backend decided for shutdown (which is not the default)

  • by PyHtmlView support when the user tries to close the window

There is a flag yaji.isrunning that is True if the backend application is not known to be stopped so far, but might even be True after a uiShutdown. It will become False when

  • _yj_pullevent requests fail (assumption: the application code side has stopped), or

  • the _yj_stopui (see above) event was received.

anise.features.ui_.web.webexec module

Module contents