class allura.lib.helpers.DateTimeConverter(*args, **kw)



The input must be a string (not a %(type)s: %(value)r)


Please enter a value


The input must be a string (not None)


Given a root-relative URL, return a full URL including protocol and host

allura.lib.helpers.ago(start_time, show_date_after=7)

Return time since starting time as a rounded, human readable string. E.g., “3 hours ago” Also works with future times E.g., “in 3 hours”

allura.lib.helpers.auditlog_user(message, *args, **kwargs)

Create an audit log entry for a user, including the IP address

allura.lib.helpers.config_with_prefix(d, prefix)

Return a subdictionary keys with a given prefix, with the prefix stripped

allura.lib.helpers.convert_bools(conf, prefix='')

For a given dict, automatically convert any true/false string values into bools. Only applies to keys starting with the prefix.




Coverts emoji codes to unicode emojis


Encodes the unicode keys of d, making the result a valid kwargs argument

class allura.lib.helpers.exceptionless(error_result, log=None)

Decorator making the decorated function return ‘error_result’ on any exceptions rather than propagating exceptions up the stack

class allura.lib.helpers.fixed_attrs_proxy(obj, **kw)

On attribute lookup, if keyword parameter matching attribute name was provided during object construction, returns it’s value. Otherwise proxies to obj.


Return current selected reaction for given react_users dict

allura.lib.helpers.get_first(d, key)

Return value for d[key][0] if d[key] is a list with elements, else return d[key].

Useful to retrieve values from solr index (e.g. title and text fields), which are stored as lists.


Return package for given tool (e.g. ‘forgetracker’ for ‘tickets’)


Get user status based on disabled and pending attrs


user – a allura.model.auth.User

allura.lib.helpers.iter_entry_points(group, *a, **kw)

Yields entry points that have not been disabled in the config.

If group is “allura” (Allura tool entry points) or one of subgroups (e.g. “”), this function also checks for multiple entry points with the same name. If there are multiple entry points with the same name, and one of them is a subclass of the other(s), it will be yielded, and the other entry points with that name will be ignored. If a subclass is not found, an ImportError will be raised.

This treatment of “allura” and “allura.*” entry points allows tool authors to subclass another tool while reusing the original entry point name.

allura.lib.helpers.log_if_changed(artifact, attr, new_val, message)

Set artifact.attr to new_val if changed. Add AuditLog record.


Override the default behavior of redirecting to the auth.login_url and instead display an overlay with content from auth.login_fragment_url.

This is to allow pages that require authentication for any actions but not for the initial view to be more apparent what you will get once logged in.

This should be wrapped around call to require_access() (presumably in the _check_security() method on a controller). The exceptions param can be given a list of exposed views to leave with the original behavior.

For example:

class MyController(BaseController);
    def _check_security(self):
        with login_overlay(exceptions=['process']):
            require_access(self.neighborhood, 'register')

    def index(self, *args, **kw):
        return {}

    def list(self, *args, **kw):
        return {}

    def process(self, *args, **kw):
        return {}

This would show the overlay to unauthenticated users who visit / or /list but would perform the normal redirect when /process is visited.

allura.lib.helpers.make_safe_path_portion(ustr, relaxed=True)

Return an ascii representation of ustr that conforms to mount point naming rules.

Will return an empty string if no char in ustr is ascii-encodable.


relaxed – Use relaxed mount point naming rules (allows more characters. See re_relaxed_tool_mount_point_fragment.


The converted string.


Temporarily swap in a new ming configuration, restoring the previous one when the contextmanager exits.


**conf – keyword arguments defining the new ming configuration


Temporarily swap in a new ming configuration, restoring the previous one when the contextmanager exits.


ini_path – Path to ini file containing the ming configuration

allura.lib.helpers.notifications_disabled(project, disabled=True)

Temporarily disable email notifications on a project.

allura.lib.helpers.null_contextmanager(returning=None, *args, **kw)

A no-op contextmanager.

allura.lib.helpers.paging_sanitizer(limit, page, total_count=9223372036854775807, zero_based_pages=True)

Return limit, page - both converted to int and constrained to valid ranges based on total_count.

Useful for sanitizing limit and page query params.

See also g.handle_paging which also checks prefs

allura.lib.helpers.push_context(project_id, mount_point=None, app_config_id=None, neighborhood=None)

A context manager to set c.project and globals temporarily. To set c.user or others, use push_config(c, user=...)

  • project_id (ObjectId|str) – _id or shortname of a project

  • mount_point (str) – mount point to set by

  • app_config_id (ObjectId|str) – alternative to mount_point parameter

  • neighborhood (str) – neighborhood full name, required if project is specified by shortname

allura.lib.helpers.querystring(request, url_params)

add/update/remove url parameters. When a value is set to None the key will be removed from the final constructed url.

  • request – request object

  • url_params – dict with the params that should be updated/added/deleted.


a full url with updated url parameters.

allura.lib.helpers.rate_limit(cfg_opt, artifact_count, start_date, exception=None)

Check the various config-defined artifact creation rate limits, and if any are exceeded, raise exception.


artifact_count – a number or callable (for lazy evaluation)

allura.lib.helpers.render_any_markup(name, txt, code_mode=False, linenumbers_style='table')

renders markdown using allura enhancements if file is in markdown format renders any other markup format using the pypeline Returns jinja-safe text

allura.lib.helpers.set_context(project_shortname_or_id, mount_point=None, app_config_id=None, neighborhood=None)

Set c.project and globals

  • project_id (ObjectId|str) – _id or shortname of a project

  • mount_point (str) – mount point to set by

  • app_config_id (ObjectId|str) – alternative to mount_point parameter

  • neighborhood (str) – neighborhood full name, required if project is specified by shortname

allura.lib.helpers.slugify(name, allow_periods=False)

Returns a tuple with slug and lowered slug based on name


xml doesn’t like some control characters: :param s: :return:

allura.lib.helpers.topological_sort(items, partial_order)

Perform topological sort. items is a list of items to be sorted. partial_order is a list of pairs. If pair (a,b) is in it, it means that item a should appear before item b. Returns a list of the items in one of the possible orders, or None if partial_order contains a loop.

Modified from:

allura.lib.helpers.unidiff(old, new)

Returns unified diff between one and two.

allura.lib.helpers.urlopen(url: str | Request, retries=3, codes=(408, 500, 502, 503, 504), timeout=None)

Open url, optionally retrying if an error is encountered.

Socket and other IO errors will always be retried if retries > 0. HTTP errors are retried if the error code is passed in codes.

  • retries – Number of time to retry.

  • codes – HTTP error codes that should be retried.


Given a relative url like /fö/bar/?sdf&sdf urlquote only the path portion of it, leaving any querystring or target hash unquoted :param url: :return: