websauna.system.form.resourceregistry module

Deform’s resource_registry mechanism to allow widgets to include CSS and JS on the page.

class websauna.system.form.resourceregistry.ResourceRegistry(request)[source]

Bases: deform.widget.ResourceRegistry

A resource registry that maintains dynamically included CSS and JS files for the page.

The best practice is to place all JavxaScript files before the closing </body> tag, so that they do not block the the page rendering and decrease the page response time. However, out there exist a lot of badly written JavaScript code which does not honour this - they have <script> tags in the middle of <body> and even worse assume you have loaded dependencies, like jQuery, in the <head>. Namely, Deform 2 form library does this.

BodyRelocatableResourceRegistry contains the logic to determine if <script> tags should go to the end of the page (preferred) or to <head> (in case some javascript makes assumptions of this). If any widget requires resources assume JS must go to head.

See also :py:attr`deform.widget.default_resources` which includes the list of default resources activated for any form on the page.

More information

get_widget_css_urls(request, form)[source]

Generate JS and CSS tags for a widget.

For demo purposes only - you might have something specific to your application here.

See http://docs.pylonsproject.org/projects/deform/en/latest/widget.html#the-high-level-deform-field-get-widget-resources-method

get_widget_js_urls(request, form)[source]

Generate JS and CSS tags for a widget.

For demo purposes only - you might have something specific to your application here.

See http://docs.pylonsproject.org/projects/deform/en/latest/widget.html#the-high-level-deform-field-get-widget-resources-method

pull_in_resources(request, form)[source]

Add resources CSS and JS resources from Deform form to a Websauna rendering loop.