Api

Admin 对象

class admin.Admin(app, url_prefix='/admin', title='flask-dashed', main_dashboard=None, endpoint='admin')[source]

Class that provides a way to add admin interface to Flask applications.

Parameters:
  • app – The Flask application
  • url_prefix – The url prefix
  • main_dashboard – The main dashboard object
  • endpoint – The endpoint
add_path_security(path, function, http_code=403)[source]

Registers security function for given path.

Parameters:
  • path – The endpoint to secure
  • function – The security function
  • http_code – The response http code
check_path_security(path)[source]

Checks security for specific and path.

Parameters:path – The path to check
register_module(module_class, url_prefix, endpoint, short_title, title=None, parent=None)[source]

Registers new module to current admin.

register_node(url_prefix, endpoint, short_title, title=None, parent=None, node_class=<class 'admin.AdminNode'>)[source]

Registers admin node.

Parameters:
  • url_prefix – The url prefix
  • endpoint – The endpoint
  • short_title – The short title
  • title – The long title
  • parent – The parent node path
  • node_class – The class for node objects

Admin 模块

admin.recursive_getattr(obj, attr)[source]

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

eg:

a = object()
a.b = object()
a.b.c = 1
recursive_getattr(a, 'b.c') => 1
recursive_getattr(a, 'b.d') => None
class admin.AdminNode(admin, url_prefix, endpoint, short_title, title=None, parent=None)[source]

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[source]

Returns all parent hierarchy as list. Usefull for breadcrumbs.

secure(http_code=403)[source]

Gives a way to secure specific url path.

Parameters:http_code – The response http code when False
url_path[source]

Returns the url path relative to admin one.

class admin.AdminModule(*args, **kwargs)[source]

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)[source]

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)[source]

Gives a way to secure specific url path.

Parameters:
  • endpoint – The endpoint to protect
  • http_code – The response http code when False
url[source]

Returns first registered (main) rule as url.

SQLAlchemy 扩展

class ext.sqlalchemy.ModelAdminModule(*args, **kwargs)[source]

SQLAlchemy model admin module builder.

count_list(search=None)[source]

Counts filtered list.

Parameters:search – The string for quick search
create_object()[source]

New object instance new object.

delete_object(object)[source]

Deletes object.

Parameters:object – The object to delete
edit_query_factory[source]

Returns query for object edition.

form_view

alias of ObjectFormView

get_actions_for_object(object)[source]

“Returns actions for object as and tuple list.

Parameters:object – The object
get_object(pk)[source]

Gets back object by primary key.

Parameters:pk – The object primary key
get_object_list(search=None, order_by_name=None, order_by_direction=None, offset=None, limit=None)[source]

Returns ordered, filtered and limited query.

Parameters:
  • search – The string for search filter
  • order_by_name – The field name to order by
  • order_by_direction – The field direction
  • offset – The offset position
  • limit – The limit
list_query_factory[source]

Returns non filtered list query.

save_object(obj)[source]

Saves object.

Parameters:object – The object to save
Fork me on GitHub