V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
qq7171891
V2EX  ›  Flask

Flask 0.11 发布了,求英文好的解说下主要新特性

  •  
  •   qq7171891 · 2016-05-30 09:25:07 +08:00 · 5520 次点击
    这是一个创建于 3136 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Version 0.11
    ------------

    Released on May 29th 2016, codename Absinthe.

    - Added support to serializing top-level arrays to :func:`flask.jsonify`. This
    introduces a security risk in ancient browsers. See
    :ref:`json-security` for details.
    - Added before_render_template signal.
    - Added `**kwargs` to :meth:`flask.Test.test_client` to support passing
    additional keyword arguments to the constructor of
    :attr:`flask.Flask.test_client_class`.
    - Added ``SESSION_REFRESH_EACH_REQUEST`` config key that controls the
    set-cookie behavior. If set to ``True`` a permanent session will be
    refreshed each request and get their lifetime extended, if set to
    ``False`` it will only be modified if the session actually modifies.
    Non permanent sessions are not affected by this and will always
    expire if the browser window closes.
    - Made Flask support custom JSON mimetypes for incoming data.
    - Added support for returning tuples in the form ``(response, headers)``
    from a view function.
    - Added :meth:`flask.Config.from_json`.
    - Added :attr:`flask.Flask.config_class`.
    - Added :meth:`flask.config.Config.get_namespace`.
    - Templates are no longer automatically reloaded outside of debug mode. This
    can be configured with the new ``TEMPLATES_AUTO_RELOAD`` config key.
    - Added a workaround for a limitation in Python 3.3's namespace loader.
    - Added support for explicit root paths when using Python 3.3's namespace
    packages.
    - Added :command:`flask` and the ``flask.cli`` module to start the local
    debug server through the click CLI system. This is recommended over the old
    ``flask.run()`` method as it works faster and more reliable due to a
    different design and also replaces ``Flask-Script``.
    - Error handlers that match specific classes are now checked first,
    thereby allowing catching exceptions that are subclasses of HTTP
    exceptions (in ``werkzeug.exceptions``). This makes it possible
    for an extension author to create exceptions that will by default
    result in the HTTP error of their choosing, but may be caught with
    a custom error handler if desired.
    - Added :meth:`flask.Config.from_mapping`.
    - Flask will now log by default even if debug is disabled. The log format is
    now hardcoded but the default log handling can be disabled through the
    ``LOGGER_HANDLER_POLICY`` configuration key.
    - Removed deprecated module functionality.
    - Added the ``EXPLAIN_TEMPLATE_LOADING`` config flag which when enabled will
    instruct Flask to explain how it locates templates. This should help
    users debug when the wrong templates are loaded.
    - Enforce blueprint handling in the order they were registered for template
    loading.
    - Ported test suite to py.test.
    - Deprecated ``request.json`` in favour of ``request.get_json()``.
    - Add "pretty" and "compressed" separators definitions in jsonify() method.
    Reduces JSON response size when JSONIFY_PRETTYPRINT_REGULAR=False by removing
    unnecessary white space included by default after separators.
    - JSON responses are now terminated with a newline character, because it is a
    convention that UNIX text files end with a newline and some clients don't
    deal well when this newline is missing. See
    https://github.com/pallets/flask/pull/1262 -- this came up originally as a
    part of https://github.com/kennethreitz/httpbin/issues/168
    - The automatically provided ``OPTIONS`` method is now correctly disabled if
    the user registered an overriding rule with the lowercase-version
    ``options`` (issue ``#1288``).
    - ``flask.json.jsonify`` now supports the ``datetime.date`` type (pull request
    ``#1326``).
    - Don't leak exception info of already catched exceptions to context teardown
    handlers (pull request ``#1393``).
    - Allow custom Jinja environment subclasses (pull request ``#1422``).
    - ``flask.g`` now has ``pop()`` and ``setdefault`` methods.
    - Turn on autoescape for ``flask.templating.render_template_string`` by default
    (pull request ``#1515``).
    - ``flask.ext`` is now deprecated (pull request ``#1484``).
    - ``send_from_directory`` now raises BadRequest if the filename is invalid on
    the server OS (pull request ``#1763``).
    - Added the ``JSONIFY_MIMETYPE`` configuration variable (pull request ``#1728``).
    - Exceptions during teardown handling will no longer leave bad application
    contexts lingering around.
    21 条回复    2016-05-31 10:39:06 +08:00
    jixiangqd
        1
    jixiangqd  
       2016-05-30 09:28:18 +08:00   ❤️ 4
    英语不好怎么干程序员的。。。?还追新特性,你知道了新特性能用的上吗?要用不还得看文档。。。
    janxin
        2
    janxin  
       2016-05-30 09:37:21 +08:00   ❤️ 1
    我还以为新版本是 1.0 ,看来还是没准备好
    qq7171891
        3
    qq7171891  
    OP
       2016-05-30 09:48:26 +08:00   ❤️ 1
    @jixiangqd
    我不是程序员。
    不知道能不能用上,就是好奇。
    是得看,目前看不懂。

    你好牛逼,大哥,牛逼哄哄。
    xuwenmang
        4
    xuwenmang  
       2016-05-30 09:51:24 +08:00   ❤️ 1
    为啥不用 thinkphp
    chengzhoukun
        5
    chengzhoukun  
       2016-05-30 09:54:56 +08:00   ❤️ 1
    @xuwenmang 太黑了
    Ixizi
        6
    Ixizi  
       2016-05-30 09:55:38 +08:00   ❤️ 1
    不要惧怕长篇阅读,事实上里面词汇都很简单。
    crazyxin1988
        7
    crazyxin1988  
       2016-05-30 09:58:39 +08:00   ❤️ 1
    看来 1.0 还要等几年啊
    mringg
        8
    mringg  
       2016-05-30 10:09:16 +08:00 via Android   ❤️ 1
    看了看,对我来说,更新的都是极少用的(比较菜,用不上太高大上的)
    不喜勿喷
    lozio
        9
    lozio  
       2016-05-30 10:52:45 +08:00   ❤️ 1
    为啥不用 thinkphp 哈哈哈哈哈哈哈哈
    Zzzzzzzzz
        10
    Zzzzzzzzz  
       2016-05-30 10:58:06 +08:00   ❤️ 1
    都不是什么新特性, 大多都是三年前就进 dev 的, 用 flask 的应该很少人还在用 0.10 吧
    pengbo37877
        11
    pengbo37877  
       2016-05-30 11:01:44 +08:00   ❤️ 1
    为啥不用 Laravel
    echo1937
        12
    echo1937  
       2016-05-30 11:03:36 +08:00 via iPhone   ❤️ 1
    @Zzzzzzzzz 萌新请教, 0.11 刚发布,之前大家用什么版本?
    9hills
        13
    9hills  
       2016-05-30 11:17:45 +08:00   ❤️ 1
    这个手伸的有点长。。。
    Zzzzzzzzz
        14
    Zzzzzzzzz  
       2016-05-30 11:19:53 +08:00   ❤️ 1
    @echo1937 就我接触过的用 flask 基本都在 github 上的开发版, flask 0.11 这些修改基本都是三年前就进仓库的, 作者本来憋个 1.0 , 后来又是去玩 rust 又是有其他想法的就耗住了, 这几年大部分推送都是针对 typo 和文档改进, 开发版比 0.10 可靠得多.
    0bit
        15
    0bit  
       2016-05-30 11:28:14 +08:00   ❤️ 1
    顺手贴一个官方地址,看着更清晰一点:
    http://flask.pocoo.org/docs/0.11/changelog/#version-0-11
    srlp
        16
    srlp  
       2016-05-30 12:51:58 +08:00   ❤️ 1
    json 相关函数改进了,引入了 flask-script 的部分设计
    evitceted
        17
    evitceted  
       2016-05-30 15:05:38 +08:00   ❤️ 1
    Flask 1.0 还没有啊?
    aljun
        18
    aljun  
       2016-05-31 01:06:34 +08:00 via iPhone   ❤️ 1
    那我前几天还自己折腾了一个 web framework⋯⋯


    贴个文档地址
    http://jolla.readthedocs.io/zh/latest/
    sqbing
        19
    sqbing  
       2016-05-31 08:21:34 +08:00
    @xuwenmang 黑的漂亮
    smallghost
        20
    smallghost  
       2016-05-31 10:25:27 +08:00
    smallghost
        21
    smallghost  
       2016-05-31 10:39:06 +08:00   ❤️ 1
    @qq7171891 已在深度开源上找到中文翻译
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1232 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 17:50 · PVG 01:50 · LAX 09:50 · JFK 12:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.