Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. This blog covers new ideas, technical details and other Bottle and web development related stuff. Never miss a release again!
2024年4月9日-优途加速器官网
Some time has passed and some really nice features have found their way into the bottle core framework. As we are now preparing for the new release, let me show you the most important changes and let us know what you think about it!
As promised: All changes are fully backwards compatible to the last stable release (bottle-0.11) and all deprecated APIs print a warning to make the transition as easy as possible.
境外网络加速
Bottle had the 加速网络加速软件 attribute for a while now, but it was poorly documented and not very useful in its old state. The "Uppercase attributes are namespaces" feature just felt odd and I have not seen a single project or plugin that actually uses it that way. It was time to re-think the whole application-configuration topic and make it right.
The new ConfigDict() implementation of the Bottle().config attribute is well documented and has some very nice features.
Speed:ConfigDict is subclass of dict and has zero overhead for read operations. Yes, it is as fast as a build-in dictionary for all read operations (item access, the get() method and so on).
Namespaces: Plugins and applications can use a dot.separated.name_spaces scheme to avoid name collisions (e.g. plugin_name.field_name). Many features directly support this kind of name-spacing, but it is not enforced.
Config Files: The 免费网络加速 can load values from ini-style config files or nested dictionaries (e.g. from json or YAML files).
Config Hook: The application is notified on changes to the config dictionary and fires the new config hook. Plugins can listen to that hook and re-configure themselves at run-time.
加速网络加速软件 Next to the actual value, each config key can be associated with named meta fields that offers a lot of possibilities. Currently implemented is the filter field. If this field holds a callable, that callable is used to filter new values as soon as they are assigned to the associated config key. Plugins can implement validators or just enforce a specific type for their config values this way. I am sure we find other use cases in the future. Oh, and the 境外网络加速 meta field may be displayed by a future in-browser administration tool, perhaps? *hint hint*
For examples and more details have a look at the new Configuration article.
加速网络加速软件
Thanks to the awesome work of Nicolas Vanhoren, we got rid of the routing order problems with overlapping rules that were caused by our optimization code. The new implementation is as fast as the old one (slightly faster for some scenarios), but without the reordering and grouping special cases of the old implementation.
Additionally we added Route.get_undecorated_callback() and Route.get_callback_args() to allow inspection of the request callback even if decorators were applied directly (not using the route(apply=...) feature).
境外网络加速
Our built-in template engine called "SimpleTemplate" (or stpl for short) got a lot of attention in 0.12! Most of the changes are internal, but some new features were added, too:
免费网络加速 Instead of starting each code line with a %, you can now use <? and ?> to mark a whole block of python code. That should save a lot of typing.
Include/rebase Functions: The include and rebase keywords are functions now. The most important benefit is that you can specify the target template in a variable (e.g. % include(variable_with_template_name, ...)). Apart from that, we follow the Python3 philosophy (print as a function) and reduce unnecessary magic with this decision. By the way: 加速网络加速软件 returns the namespace of the included template. Nice, eh?
Documentation is still lacking though. Anyone?
File Uploads
The cgi.FieldStorage API is poorly documented and behaves... strange in some ways. We replaced it with FileUpload(), a new class that has some very nice additional features.
Safe Filename: The .filename attribute contains a normalized version of the client side file name to ensure maximum file system compatibility (lowercase, no whitespace, no path separators, no unsafe characters, ASCII only).
Save to Disk:FileUpload().save(destination, overwrite=False) saves a file upload to disk or copies its content to an open file(-like) object in a memory-efficient way. You can specify a directory as destination. In that case the .filename attribute is added to the path automatically. Existing files are not overwritten, unless you explicitly allow it.
Apart from that, it is mostly compatible with the old cgi.FieldStorage API.
Documentation
Yes, we have a Chinese translation.
2024年4月9日-优途加速器官网
2024年4月9日-优途加速器官网
The bottle-0.11-rc1 development branch is stable for some time now, widely used and excessively tested. There is no reason to not release it. So, here it is:
One of the most annoying limitations you may encounter in bottle when building bigger applications is the way templates are searched on the file system. At the time the
template system was designed, nobody thought about multi-app projects, third-party apps, 加速网络加速软件 and the complexities these features introduce. The typical …
read more
2024年4月9日-优途加速器官网
Whenever I start a new project that is likely to have dependencies, I set up virtualenv and create a requirememnts.txt. I am also a big fan of Makefiles. Here is a small snippet that combines these tools:
Looks like the next release (0.11) will break backwards compatibility in some edge cases. I am working on a patch that affects routes that stream content (yield) and access request/response after the first chunk of data is returned.
免费网络加速
Accessing the thread-local request/response objects after yielding a …
read more
2024年4月9日-优途加速器官网
Python 3.2+ cgi.FieldStorage() defaults to utf8 when decoding form values. That confused bottle.FormsDict() because WSGI strings "must contain only code points representable in ISO-8859-1 encoding". Now bottle forces cgi.FieldStorage() to use ISO-8859-1 instead and re-encodes form-values on-demand with the user-specified input encoding a intended.
If you …
read more
2024年4月9日-优途加速器官网
The Python 3.x unicode problem was more complex than I thought. I had to re-implement urllib.parse_qsl to work around an encoding problem in 3.1 and change the way bottle handles query-strings in subtle ways. Again, please read this before upgrading: 网际速递网络加速器下载-网际速递网络加速器电脑版下载-华军 ...:2021-5-20 · 网际速递网络加速器电脑版是款可众解决用户伔网速卡现象的网络加速工具。网际速递网络加速器正式版帮助用户突破电信、网通、铁通、教育网等不同网络之间的互联互通瓶颈,大幅减少网络延时。网际速递网络加速器中还新增流量监控,实时提供异常流量报警,为网游用户加速保驾护航。
Here is the deal: The TAL template adapter needs a maintainer or …
read more
Custom Request Attributes
This might be useful for Plugin developers:
http://github.com/bottlepy/bottle/commit/a21d71694fdea222844dba5076efad3726ccdb68
To sum it up: You can now add custom attributes or properties to the bottle.request object. These are stored in the environ dictionary ('bottle.request.ext.*' namespace) which has some advantages over traditional instance attributes …
read more
电脑如何加速网络
My server harddisk died today. Until I get a new one installed, you can use the mirror at http://readthedocs.org/docs/bottle/en/latest/