autobreadcrumbs
latest
  • Install
  • Overview
  • Settings
  • Template tags
  • Site registry for breadcrumb definitions
  • Crumb definitions discovering
  • Breadcrumb resolving
  • Template context processor
  • Development
  • Changelog
autobreadcrumbs
  • Docs »
  • Breadcrumb resolving
  • Edit on GitHub

Breadcrumb resolving¶

class autobreadcrumbs.resolver.BreadcrumbRessource(path, name, title, view_args, view_kwargs)[source]¶

Simple crumb ressource model to contain all datas about a ressource.

class autobreadcrumbs.resolver.PathBreadcrumbResolver(root_urlconf)[source]¶

Resolve given path as breadcrumbs

Parameters:root_urlconf (string) – Python path to an url conf file, usually settings.ROOT_URLCONF. It will be used as the url map to resolve every given path.
cut(path)[source]¶

Cut given path into segments

Parameters:path (string) – An url path like /foo/bar/.
Returns:List of path segments, each segment is a part of the url path starting from / and ending on the full path.

Such as for /foo/bar/ segments will be:

- /
- /foo
- /foo/bar
Return type:list
format_title(value)[source]¶

Manage title format

Parameters:
  • name (string) – Url name.
  • value (string) – Crumb value.
Keyword Arguments:
 

request (django.http.request.HttpRequest) – Optional Django request object used with custom crumb function. If not given, crumb functions is ignored (so the crumb ressource still be available).

Returns:

Crumb title.

Return type:

string

get_current(elements)[source]¶

Return current Breadcrumb from elements.

This is pretty simple as the current element is allways the last element (if element list is not empty).

Parameters:elements (list) – List of breadcrumb elements.
Returns:The last element from given elements if any, else None.
Return type:BreadcrumbRessource or None
resolve(path, request=None)[source]¶

Return resolved breadcrumbs datas from given path.

Cut the path in segments and check each of them to find breadcrumb details if any.

Crumb value can be a simple string, a Django lazy unicode or a tuple (title, custom_function).

Crumb custom_function take url name and request object as arguments and will return False to ignore crumb (won’t be in breadcrumbs) or True to keep crumb element.

Parameters:path (string) – An url path like /foo/bar/.
Keyword Arguments:
 request (django.http.request.HttpRequest) – Optional Django request object used with custom crumb function. If not given, crumb functions will be ignored (so the crumb ressources still be available).
Returns:Datas from resolved crumbs:
  • autobreadcrumbs_elements: Resolved bread crumbs for each segment;
  • autobreadcrumbs_current: Breadcrumb for current (the last one) path.
Return type:Dict
Next Previous

© Copyright 2016, David THENON. Revision 4de2335e.

Built with Sphinx using a theme provided by Read the Docs.