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’ssettings
dict and prepared for use.-
assets
= {}¶
-
image_filters
= []¶
-
includes
= []¶
-
less_path
= '/_pfe/less.js'¶
-
lessc_path
= None¶
-
require_base_url
= '/_pfe/'¶
-
require_config_path
= '/_pfe/require_config.js'¶
-
require_path
= '/_pfe/require.js'¶
-
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'¶
-
-
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.
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.
compile_asset
(theme, output_dir, key, entry_point, asset_type, minify)[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.
-
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 exact 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'}¶
-