tailbone.util

Utilities

class tailbone.util.SortColumn(field_name, model_name=None)[source]

Generic representation of a sort column, for use with sorting grid data as well as with API.

tailbone.util.email_address_is_valid(address)[source]

Returns boolean indicating whether the address can validate.

tailbone.util.get_available_themes(rattail_config, include=None)[source]

Returns a list of theme names which are available. If config does not specify, some defaults will be assumed.

tailbone.util.get_effective_theme(rattail_config, theme=None, session=None)[source]

Validates and returns the “effective” theme. If you provide a theme, that will be used; otherwise it is read from database setting.

tailbone.util.get_form_data(request)[source]

DEPECATED - use wuttaweb.util.get_form_data() instead.

tailbone.util.get_global_search_options(request)[source]

Returns global search options for current request. Basically a list of all “index views” minus the ones they aren’t allowed to access.

tailbone.util.get_liburl(request, key, fallback=True)[source]

DEPRECATED - use wuttaweb.util.get_liburl() instead.

tailbone.util.get_libver(request, key, fallback=True, default_only=False)[source]

DEPRECATED - use wuttaweb.util.get_libver() instead.

tailbone.util.get_theme_template_path(rattail_config, theme=None, session=None)[source]

Retrieves the template path for the given theme.

tailbone.util.include_configured_views(pyramid_config)[source]

Include arbitrary additional views based on DB settings.

tailbone.util.pretty_datetime(config, value)[source]

Formats a datetime as a “pretty” human-readable string, with a tooltip showing the ISO string value.

Parameters:
  • config – Reference to a config object.

  • value – A datetime.datetime instance. Note that if this instance is not timezone-aware, its timezone is assumed to be UTC.

tailbone.util.raw_datetime(config, value, verbose=False, as_date=False)[source]

Formats a datetime as a “raw” human-readable string, with a tooltip showing the more human-friendly “time since” equivalent.

Parameters:
  • config – Reference to a config object.

  • value – A datetime.datetime instance. Note that if this instance is not timezone-aware, its timezone is assumed to be UTC.

tailbone.util.render_markdown(text, raw=False, **kwargs)[source]

Render the given markdown text as HTML.

tailbone.util.route_exists(request, route_name)[source]

Checks for existence of the given route name, within the running app config. Returns boolean indicating whether it exists.

tailbone.util.set_app_theme(request, theme, session=None)[source]

Set the app theme. This modifies the global Mako template lookup directory path, i.e. theme for all users will change immediately.

This also saves the setting for the new theme, and updates the running app registry settings with the new theme.

tailbone.util.should_use_oruga(request)[source]

Returns a flag indicating whether or not the current theme supports (and therefore should use) Oruga + Vue 3 as opposed to the default of Buefy + Vue 2.

tailbone.util.validate_email_address(address)[source]

Perform basic validation on the given email address. This leverages the colander package for actual validation logic.