Admin 模块

admin.recursive_getattr(obj, attr)

Returns object related attributes, as it’s a template filter None is return when attribute doesn’t exists.

eg:

  1. a = object()
  2. a.b = object()
  3. a.b.c = 1
  4. recursive_getattr(a, 'b.c') => 1
  5. recursive_getattr(a, 'b.d') => None

class admin.AdminNode(admin, url_prefix, endpoint, short_title, title=None, parent=None)

An AdminNode just act as navigation container, it doesn’t provide any rules.

Parameters:

  • admin – The parent admin object
  • url_prefix – The url prefix
  • enpoint – The endpoint
  • short_title – The short module title use on navigation & breadcrumbs
  • title – The long title
  • parent – The parent node

parents

Returns all parent hierarchy as list. Usefull for breadcrumbs.

secure(http_code=403)

Gives a way to secure specific url path.

Parameters: http_code – The response http code when False

url_path

Returns the url path relative to admin one.

class admin.AdminModule(*args, **kwargs)

Class that provides a way to create simple admin module.

Parameters:

  • admin – The parent admin object
  • url_prefix – The url prefix
  • enpoint – The endpoint
  • short_title – the short module title use on navigation & breadcrumbs
  • title – The long title
  • parent – The parent node

add_url_rule(rule, endpoint, view_func, **options)

Adds a routing rule to the application from relative endpoint. view_class is copied as we need to dynamically apply decorators.

Parameters:

  • rule – The rule
  • endpoint – The endpoint
  • view_func – The view

secure_endpoint(endpoint, http_code=403)

Gives a way to secure specific url path.

Parameters:

  • endpoint – The endpoint to protect
  • http_code – The response http code when False

url

Returns first registered (main) rule as url.