<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 歡迎來到 Flask_Dashed 的文檔! ## 介紹 Flask-Dashed 提供構建簡單以及具有擴展性的管理界面的工具。 在線演示: [http://flask-dashed.jeanphi.fr/](http://flask-dashed.jeanphi.fr/) (需要 Github 賬號)。 列表視圖: ![https://box.kancloud.cn/2016-03-12_56e38c26c27ad.png](https://box.kancloud.cn/2016-03-12_56e38c26c27ad.png) 表單視圖: ![https://box.kancloud.cn/2016-03-12_56e38c26dd0ab.png](https://box.kancloud.cn/2016-03-12_56e38c26dd0ab.png) ## 安裝 ``` pip install Flask-Dashed ``` ## 最小的使用 代碼: ``` from flask import Flask from flask_dashed.admin import Admin app = Flask(__name__) admin = Admin(app) if __name__ == '__main__': app.run() ``` 示例應用程序: [http://github.com/jeanphix/flask-dashed-demo](http://github.com/jeanphix/flask-dashed-demo) ## 安全地處理 保護(“武裝”)所有模塊端: ``` from flask import session book_module = admin.register_module(BookModule, '/books', 'books', 'book management') @book_module.secure(http_code=401) def login_required(): return "user" in session ``` 保護(“武裝”)特定的模塊端: ``` @book_module.secure_endpoint('edit', http_code=403) def check_edit_credential(view): # I'm now signed in, may I modify the ressource? return session.user.can_edit_book(view.object) ``` ## 模塊組織 由于管理節點( node )注冊到一個“樹”,因此很容易地管理它們。: ``` library = admin.register_node('/library', 'library', my library) book_module = admin.register_module(BookModule, '/books', 'books', 'book management', parent=library)``` 為了滿足你的需求,導航和面包屑會自動地建立。子模塊的安全將會繼承自父模塊。 ## SQLALchemy 擴展 Code: ``` from flask_dashed.ext.sqlalchemy import ModelAdminModule class BookModule(ModelAdminModule): model = Book db_session = db.session book_module = admin.register_module(BookModule, '/books', 'books', 'book management') ``` # Api ## Admin 對象 `class admin.Admin(app, url_prefix='/admin', title='flask-dashed', main_dashboard=None, endpoint='admin')` 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)` 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)` 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)` Registers new module to current admin. `register_node(url_prefix, endpoint, short_title, title=None, parent=None, node_class=<class 'admin.AdminNode'>)` 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)` 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)` 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. ## SQLAlchemy 擴展 `class ext.sqlalchemy.ModelAdminModule(*args, **kwargs)` SQLAlchemy model admin module builder. `count_list(search=None)` Counts filtered list. Parameters: **search** – The string for quick search `create_object()` New object instance new object. `delete_object(object)` Deletes object. Parameters: **object** – The object to delete `edit_query_factory` Returns query for object edition. `form_view` alias of `ObjectFormView` `get_actions_for_object(object)` “Returns actions for object as and tuple list. Parameters: **object** – The object `get_object(pk)` 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)` 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` Returns non filtered list query. `save_object(obj)` Saves object. Parameters: **object** – The object to save
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看