API Reference

class pyramid_frontend.theme.Theme(settings)[source]

Represents a collection of templates, static files, image filters, and configuration corresponding to a particular visual theme (or “skin”) used by the application.

New themes are created by subclassing from this class. When passed to config.add_theme(), The subclass will be instantiated with the application’s settings dict and prepared for use.

assets = {}
cache_args = None
cache_impl = None
compile(minify=True)[source]
compiled_asset_path(key)[source]
image_filters = []
includes = []
keyed_static_dirs[source]
lookup[source]
lookup_nofilters[source]
opt(key, default=<object object>)[source]
classmethod qualify_path(path)[source]
stacked_assets[source]
stacked_image_filters[source]
stacked_includes[source]
static(path)[source]
static_dir = 'static'
static_url_to_filesystem_path(url)[source]

Given a URL of the structure /_<theme key>/<path>, locate the static dir which corresponds to the theme key and re-qualify the <path> to that directory.

template_dir = 'templates'
template_dirs[source]
classmethod traverse_attributes(name, qualify_paths=False)[source]
pyramid_frontend.theme.add_theme(config, cls)[source]

A Pyramid config directive to initialiaze and register a theme for use.

pyramid_frontend.theme.default_theme_strategy(request)[source]

The default theme selection strategy: just checks the pyramid_frontend.theme settings key.

pyramid_frontend.theme.includeme(config)[source]
pyramid_frontend.theme.set_theme_strategy(config, strategy_func)[source]

A Pyramid config directive to set a customized theme-selection strategy for each request.

pyramid_frontend.theme.theme(request)[source]

The theme instance that should be used for this request. This property is both lazily-evaluated and reified.

pyramid_frontend.assets.asset_tag(request, key, **kwargs)[source]

Request method to render an HTML fragment containing tags which reference the supplied entry point. This will dispatch to the appropriate tag rendering function based on context and entry point type.

pyramid_frontend.assets.includeme(config)[source]
class pyramid_frontend.images.FilterChain(suffix, filters=(), extension='png', width=None, height=None, no_thumb=False, pad=False, crop=False, crop_whitespace=False, background='white', enlarge=False, **saver_kwargs)[source]

A chain of image filters (a.k.a. “pipeline”) used to process images for a particular display context.

basename(name, original_ext)[source]
run(dest_path, image_data)[source]
run_chain(image_data)[source]
write(dest_path, filtered)[source]
exception pyramid_frontend.images.MissingOriginal(path, chain)[source]
pyramid_frontend.images.save_image(settings, name, original_ext, f)[source]
pyramid_frontend.images.save_to_error_dir(settings, name, f)[source]

Save a questionable image (could not be verified by PIL) to a penalty box for investigation.

pyramid_frontend.images.check(f)[source]

Given a file object, check to see if the contents is a valid image. If so, return the file format. Otherwise, raise exceptions.

class pyramid_frontend.compile.ConsoleHandler(stream=None)[source]

A subclass of StreamHandler which behaves in the same way, but colorizes the log level before formatting it.

colors = {'INFO': '\x1b[1;32m', 'WARNING': '\x1b[1;33m', None: '\x1b[0m', 'CRITICAL': '\x1b[1;31m', 'ERROR': '\x1b[1;31m', 'DEBUG': '\x1b[1;37m'}
emit(record)[source]

Emit a record.

If a formatter is specified, it is used to format the record, but before the formatter is applied the loglevel is colored.

pyramid_frontend.compile.compile(registry, minify=True)[source]

Compile static assets for all themes which are registered in registry.

pyramid_frontend.compile.configure_logging(verbosity)[source]

Configure logging for use with the asset compilation command.

pyramid_frontend.compile.main(args=['/home/docs/checkouts/readthedocs.org/user_builds/pyramid-frontend/envs/latest/bin/sphinx-build', '-T', '-E', '-b', 'readthedocs', '-d', '_build/doctrees-readthedocs', '-D', 'language=en', '.', '_build/html'])[source]

Main entry point for the executable which compiles assets.