Fanstatic WSGI framework component.
| Parameters: |
|
|---|
Serf WSGI application.
Serve a very simple HTML page while needing a resource. Can be configured behind the Fanstatic() WSGI framework component to let the resource be included.
| Parameters: | resource – The Resource to include. |
|---|
Fanstatic injector WSGI framework component.
This WSGI component takes care of injecting the proper resource inclusions into HTML when needed.
This WSGI component is used automatically by the Fanstatic() WSGI framework component, but can also be used independently if you need more control.
| Parameters: |
|
|---|
Fanstatic publisher WSGI application.
This WSGI application serves Fanstatic Library instances. Libraries are published as <library_name>/<optional_version>/path/to/resource.js.
All static resources contained in the libraries will be published to the web. If a step prefixed with :version: appears in the URL, this will be automatically skipped, and the HTTP response will indicate the resource can be cached forever.
This WSGI component is used automatically by the Fanstatic() WSGI framework component, but can also be used independently if you need more control.
| Parameters: | library_registry – an instance of LibraryRegistry with those resource libraries that should be published. |
|---|
Fanstatic directory publisher WSGI application.
This WSGI application serves a directory of static resources to the web.
This WSGI component is used automatically by the Fanstatic() WSGI framework component, but can also be used independently if you need more control.
| Parameters: | library – The fanstatic library instance. |
|---|
Fanstatic delegator WSGI framework component.
This WSGI component recognizes URLs that point to Fanstatic libraries, and delegates them to the Publisher WSGI application.
In order to recognize such URLs it looks for occurrences of the publisher_signature parameter as a URL step. By default it looks for /fanstatic/.
This WSGI component is used automatically by the Fanstatic() WSGI framework component, but can also be used independently if you need more control.
| Parameters: |
|
|---|
The resource library.
This object defines which directory is published and can be referred to by Resource objects to describe these resources.
| Parameters: |
|
|---|
This can only be called once all resources are known.
i.e. once sort_resources is called this can be called. once library numbers are calculated once this will be done very quickly.
The absolute path to the directory which contains the static resources this library publishes.
Register a Resource with this Library.
A Resource knows about its Library. After a Resource has registered itself with its Library, the Library knows about the Resources associated to it.
Get a unique signature for this Library.
If a version has been defined, we return the version.
If no version is defined, a hash of the contents of the directory indicated by path is calculated. If recompute_hashes is set to True, the signature will be recalculated each time, which is useful during development when changing Javascript/css code and images.
A resource.
A resource specifies a single resource in a library so that it can be included in a web page. This is useful for Javascript and CSS resources in particular. Some static resources such as images are not included in this way and therefore do not have to be defined this way.
| Parameters: |
|
|---|
Get Resource in another mode.
If the mode is None or if the mode cannot be found, this Resource instance is returned instead.
| Parameters: | mode – a string indicating the mode, or None. |
|---|
Declare that the application needs this resource.
If you call .need() on Resource sometime during the rendering process of your web page, this resource and all its dependencies will be inserted as inclusions into the web page.
| Parameters: | slots – an optional dictionary mapping from Slot instances to Resource instances. This dictionary describes how to fill in the slots that this resource might depend on (directly or indirectly). If a slot is required, the dictionary must contain an entry for it. |
|---|
A resource slot.
Sometimes only the application has knowledge on how to fill in a dependency for a resource, and this cannot be known at resource definition time. In this case you can define a slot, and make your resource depend on that. This slot can then be filled in with a real resource by the application when you .need() that resource (or when you need something that depends on the slot indirectly).
| Parameters: |
|
|---|
A resource used to group resources together.
It doesn’t define a resource file itself, but instead depends on other resources. When a Group is depended on, all the resources grouped together will be included.
| Parameters: | depends – a list of resources that this resource depends on. Entries in the list can be Resource instances, or Group instances. |
|---|
Need this group resource.
If you call .need() on Group sometime during the rendering process of your web page, all dependencies of this group resources will be inserted into the web page.
| Parameters: | slots – an optional dictionary mapping from Slot instances to Resource instances. This dictionary describes how to fill in the slots that this resource might depend on (directly or indirectly). If a slot is required, the dictionary must contain an entry for it. |
|---|
The current selection of needed resources..
The NeededResources instance maintains a set of needed resources for a particular web page.
| Parameters: |
|
|---|
Returns True if base_url has been set.
Returns True if any resources are needed.
Construct URL to library.
This constructs a URL to a library, obey versioning and base_url configuration.
| Parameters: | library – A Library instance. |
|---|
Add a particular resource to the needed resources.
This is an alternative to calling .need() on the resource directly.
| Parameters: |
|---|
Render needed resource inclusions.
This returns a string with the rendered resource inclusions (<script> and <link> tags), suitable for including in the <head> section of a web page.
Render a set of resources as inclusions.
This renders the listed inclusions and their dependencies as HTML ((<script> and <link> tags), suitable for inclusion on a web page.
| Parameters: | inclusions – A list of Resource instances. |
|---|
Render needed resource inclusions into HTML.
| Parameters: | html – A string with HTML to render the resource inclusions into. This string must have a <head> section. |
|---|
Render resource inclusions separately into top and bottom fragments.
Returns a tuple of two HTML snippets, top and bottom. The top one is to be included in a <head> section, and the bottom one is to be included at the end of the <body> section. Only bottom safe resources are included in the bottom section, unless force_bottom is enabled, in which case all Javascript resources will be included in the bottom.
Render needed resource inclusions into HTML.
Only bottom safe resources are included in the bottom section, unless force_bottom is enabled, in which case all Javascript resources will be included in the bottom, just before the </body> tag.
| Parameters: | html – The HTML string in which to insert the rendered resource inclusions. This string must have a <head> and a <body> section. |
|---|
Retrieve the list of resources needed.
This returns the needed Resource instances. Resources are guaranteed to come earlier in the list than those resources that depend on them.
Resources are also sorted by extension.
Set the base_url. The base_url can only be set (1) if it has not been set in the NeededResources configuration and (2) if it has not been set before using this method.
Bases: fanstatic.registry.Registry
A dictionary-like registry of libraries.
This is a dictionary that mains libraries. A value is a Library instance, and a key is its library name.
Normally there is only a single global LibraryRegistry, obtained by calling get_library_registry().
| Parameters: | libraries – a sequence of libraries |
|---|
Bases: exceptions.Exception
Impossible or illegal configuration.
Bases: exceptions.Exception
Resource refers to non-existent resource file.
Bases: exceptions.Exception
A resource has an unrecognized extension.
Bases: exceptions.Exception
Dependency cycles between libraries aren’t allowed.
A dependency cycle between libraries occurs when the file in one library depends on a file in another library, while that library depends on a file in the first library.
Bases: exceptions.Exception
A slot was filled in incorrectly.
If a slot is required, it must be filled in by passing an extra dictionary parameter to the .need method, containing a mapping from the required Slot to Resource.
When a slot is filled, the resource filled in should have the same dependencies as the slot, or a subset of the dependencies of the slot. It should also have the same extension as the slot. If this is not the case, it is an error.
Register a renderer function for a given filename extension.
| Parameters: |
|
|---|
Set resource file existence checking to True or False.
By default, this is set to True, so that resources that point to non-existent files will result in an error. We recommend you keep it at this value when using Fanstatic. An UnknownResourceError will then be raised if you accidentally refer to a non-existent resource.
When running tests it’s often useful to make fake resources that don’t really have a filesystem representation, so this is set to False temporarily; for the Fanstatic tests this is done. Inside a test for this particular feature, this can temporarily be set to True.