Changelog: older releases
What changed in each release before 0.7.0. The changelog has the releases since.
0.6.0
Changed in 0.6.0
The kinds in a filename are words:
page,early, andlate. A page handler was named.ex., an early hook.eh., and a late hook.lh., and nothing said what the letters stood for. The kind is now the word this documentation uses for it:users.page.get.py,admin.early.default.py,admin.late.default.py..tree.handlers and error handlers keep their names. Rename every handler and hook file when you upgrade. A file that keeps its old name is no longer a handler or a hook. It does not run and nothing reports it, so a hook that checks a login would stop checking. This script renames every such file beneath the directory it is run in:# rename_handlers.py: run it once, in the directory that holds your webapps import pathlib import re new_kind = {"ex": "page", "eh": "early", "lh": "late"} for path in pathlib.Path(".").rglob("*.py"): name = re.sub(r"\.(ex|eh|lh)(\.[^.]+\.py)$", lambda found: f".{new_kind[found[1]]}{found[2]}", path.name) if name != path.name: path.rename(path.with_name(name))
A file is sent only where a handler sends it. Every file in a webapp’s tree that was not Python used to be public at its own path, as in the directory of a PHP site. A file that landed in the tree by mistake, such as a database, an export, or a template, was sent to anyone who asked for it. No file is sent by itself any more. Cylinder’s file server is now an ordinary page handler,
cylinder.static_file, and a file is sent only beneath a handler file that uses it. After upgrading, every static file gets a404until a handler serves it. For each directory of files for the browser, add<directory>.tree.get.pybeside it, with the one linefrom cylinder import static_file as main. For a single file such asrobots.txt, addrobots.txt.page.get.pybeside it with the same line. To serve every file in the site as before, put the line in<webapp>.tree.get.py, beside the webapp’s directory. Three things follow from the file server being a page handler. A page handler closer to the URL answers in its place, where a file used to win over every handler. A request with another method gets a405, as it does at any other page. And a handler of your own can callstatic_fileand change the response it returns, which takes the place of a late hook that has to check the status.cylinder.DirectFileServe, which was never documented, is gone. See Static files.A request that no page handler serves gets a
404or a405, and no longer a501. A request with any method butGETandHEADthat no page handler served got501 Not Implemented, whether or not anything was at the URL. A501is a server error, so aPOSTto a URL that never existed counted against the server in its monitoring, and the response told a client nothing about what the URL does accept. The response now says what is at the URL. If it has no page handler for any method, that is a404 Not Found, whatever the method. If it has one for other methods, it is a405 Method Not Allowed, and theAllowheader lists the methods that have a file.GETis no exception: aGETto a URL that has only a.postfile used to get a404, and now gets a405. A method that no file can be named for still gets a501. If a site has an error handler file for501, name it for405, and check that its404handler suits a request with any method. If a test, a client, or a monitor expects one of the old statuses, change what it expects. A.defaultpage handler that only callsabort(405)can be removed. See When nothing matches.Log lines are written by the request, and no longer by a background thread. Cylinder put every log record on a queue for a background thread to write, so that a slow log handler could not hold up a response. Handing each record to that thread cost more than writing it. Where it was measured, behind an HTTP server on Linux that served one request at a time, a small page was served 10 percent faster without the thread at the
INFOlevel and 33 percent faster atDEBUG. Each record is now written by the thread that logs it, so the lines of a request are written by the time its response is returned.app.wait_for_logs,app.log_queue, andcylinder.log_queue_lengthare gone, and so is the rule that the oldest waiting records are dropped when the queue is full. Removeapp.wait_for_logs = Truefrom your tests: there is nothing left to wait for. If yourlog_handleris slow, as one that sends each record over the network is, give it a thread of its own, or it holds up every response that logs. See A slow log handler.Every file is found in the listing of its directory. 0.5.0 began to keep the names in each directory on the way to a URL, and used them to tell a name from the value of a placeholder. Handlers, hooks, error handlers, and static files were still looked for on disk on every request, one possible filename at a time. They are now looked up in the same listings, so a request asks the disk about each directory once, and not about each file that might be in it. Where it was measured, a page three directories down with two hooks above it took a third less time on Linux and half the time on Windows. Which file answers a URL has not changed. What has changed is how far a stale listing reaches. If a deployment tool puts the modification time of a directory back after adding or removing a file in it, no file it added is found and a file it removed gets a
500, until that time changes or the app restarts. That used to affect placeholders only. Restart the app after deploying with such a tool. See Reloading and restarts.
Fixed in 0.6.0
A handler file saved twice in one second is no longer served from its first save. Cylinder keeps the compiled code of a handler file until the file’s modification time or size changes. Some filesystems keep times in whole seconds, and there a second save in the same second that left the size as it was looked like no change: the old code kept answering until the file was saved again. The code is now kept only once the file’s modification time is more than two seconds old, which is the rule the listing of a directory already followed. See Reloading and restarts.
Documentation in 0.6.0
Routing says that links are passed over: nothing is served or run through a symbolic link or a Windows junction. That was already so, and nothing said it. Security adds what follows for a hook that is a link.
Building a JSON API no longer writes a
.defaultfile for each resource to refuse other methods, because the405now needs no code.Static files has a page of its own. It holds the sections on caching, compressed files, and what is never served, which were part of Routing, and Routing keeps a short section that points to it. The recipes that set headers on files now call
static_filefrom a handler.
0.5.0
Changed in 0.5.0
A page handler serves the paths beneath it only when it is named
.tree.A handler used to take on the paths beneath its own by asking forremainder, so a parameter decided routing. The filename decides it now, like everything else about a route:files.tree.get.pyserves/filesand every path beneath it that has no closer match, andfiles.ex.get.pyserves/filesonly. Rename every page handler that serves deeper paths from<name>.ex.<method>.pyto<name>.tree.<method>.py. They are the page handlers that haveremainderamong their parameters. One that is not renamed serves its own path only: the URLs beneath it get a404, or a501for a method other thanGETandHEAD, and itsremainderis always[].remainderis still passed to any handler, hook, or error handler that asks for it, and asking no longer changes anything. At the same path and for the same method, an.ex.file wins over a.tree.file. A handler file that is passed over is no longer run to see what it asks for, so the code at the top of it does not run for that request. See Handlers for a whole tree.A name in braces is a placeholder. A file or directory named
{name}, wherenameis a Python identifier, now answers for any one segment of a URL. It used to match only a segment spelled the same way, braces included. If a webapp has a file or directory with such a name, rename it.A file that is added, removed, or renamed is noticed through the modification time of its directory. Cylinder used to look for each file by name on every request. It now reads the names in each directory on the way to a URL, keeps them, and reads them again when the modification time of the directory changes. If a deployment tool puts the modification times of directories back after changing what is in them, restart the app after deploying. See Reloading and restarts.
A URL is served in one spelling only.
/users/,/users//123,/./users,/x/../users, and a path with a backslash in it used to be answered as the URL they resemble. A rule in a reverse proxy, a firewall, or a CDN that named/admindid not apply to//adminor/admin/, and Cylinder served the page all the same. Such a URL is now answered like any other that no page serves: the hooks on the way to it run, and then the error handler for404, or for501when the method is notGETorHEAD. If a link, a form, or a client of an API uses a URL with a slash at the end or a slash too many, correct it, or add the hook that redirects. See One spelling for each URL.The exception classes for redirects have no names of their own.
cylinder.RedirectFoundand the four classes like it are gone.cylinder.HTTPRedirect, which every redirect is an instance of, is unchanged, ande.codesays which redirect it is. Nothing in the documentation used the names, so this matters only to code that caught one of them.
Fixed in 0.5.0
What a
500handler aborts with is final, whatever it is answering for. When an error handler raised an exception and the500handler then redirected or aborted with another status, the client got a plain500. It now gets what the500handler chose, as it already did when the exception came from a page handler. See Aborting from an error handler.
Added in 0.5.0
Placeholders put the dynamic part of a URL in a filename.
users/{user_id}.ex.get.pyhandles/users/123, andmain()can ask foruser_id, which is"123". A placeholder stands for exactly one segment, so/users/123/extrais a404without any code. It can be a directory, which routes a nested URL such as/users/123/posts/456, and hooks and error handlers can be named with one. A file or directory named for a segment always wins over a placeholder. See Placeholders.Python 3.14 and 3.15 are listed as supported. The tests now run on Python 3.15, the newest release, as well as on 3.10, the oldest that Cylinder supports.
Documentation in 0.5.0
Building a JSON API uses a placeholder for
/API/users/<id>, so its handlers no longer take a path apart. Its new section on nested resources replaces the advice in Routing to keep URLs flat, which described a limit that placeholders remove.Security explains that a placeholder’s value comes from the client.
0.4.1
Fixed in 0.4.1
A long URL no longer costs more than a short one. Cylinder looked for handler files at every segment of a URL, including the segments below a directory that does not exist, where no file can be. The time and memory a request took grew with the square of the number of segments. Where it was measured, a URL of 4,000 segments, which fits in 8 KB, took over a second and about 100 MB, so one client could keep a server busy with such requests. The search now stops at the first directory that does not exist. Which file answers a URL has not changed, and
remainderstill holds every segment.Matching is case-sensitive on every filesystem that ignores letter case, not only on Windows. The default filesystem of macOS, and a Windows drive used from Linux, open a file by its name in any letter case. Cylinder turned such a match down on Windows only. Elsewhere
/USERSwas answered byusers.ex.get.py, a static file was served under any spelling of its path, and a webapp name in the wrong case worked. A check that comparesrequest.pathwith a fixed string, such as a hook at the root that asks for a login under/admin, could be passed by asking for/ADMIN. A name now matches only in the letter case it has on disk. If a link, a URL in a test, or the webapp name inapp_map()was in the wrong case and worked on macOS, it now gets a404there, as it always did on Linux and Windows. On a filesystem that ignores case, outside Windows, the spelling is read from the listing of the directory, so a request into a directory with thousands of files takes longer there.
Changed in 0.4.1
A method that no file can be named for gets
501 Not Implemented. A request whose method is not alphabetic, such asM-SEARCH, or is the reservedDEFAULT, used to get a500and a logged traceback, so a client could set off a site’s500handler at will. It is now turned down like any other request that no page handler serves: the.defaulthooks run, and the error handler for501answers. See When nothing matches.
Documentation in 0.4.1
Routing explains why to keep URLs flat: nothing is routed beneath a dynamic segment, so
/users/123/posts/456is better served as/posts/456, with relationships such as/posts?user=123in the query string.
0.4.0
Changed in 0.4.0
A page handler serves the paths beneath it only if it asks for
remainder. A handler used to answer for every path beneath its own that had no closer match, so an unknown URL returned200unless the handler checkedremainderand calledabort(404). A handler withoutremainderin its signature now serves its own path only. For a path beneath it, it is passed over as if it were not there, and the request goes to the nearest handler above that does ask. A handler that already asks forremainderbehaves as before. If a handler of yours answers for deeper paths without asking, for example a root handler that looks atrequest.path, addremainderto its parameters. A check such asif remainder: abort(404)in a handler that takes no dynamic segments can be removed, together with the parameter. See Dynamic paths.A
GETorHEADthat no page handler serves gets404 Not Found. It used to get501 Not Implemented, which every other method still gets. This is also the answer for a static file that does not exist, on a site with no page handler above it. See When nothing matches.The early hook runs before a request that no page handler serves is turned down. It used to be skipped for such a request. A hook that checks authentication now answers before the
404does, and the headers and cookies an early hook sets are on the404or501response.Every hook between the site root and the URL runs. Cylinder used to run one early hook and one late hook for a request, the closest of each, so a hook added for a section switched off the hooks above it there. Early hooks now run from the site root down to the URL, and late hooks from the URL back up, with one hook of each kind per path. An authentication check in a hook at the root can no longer be lost, and a late hook at the root has the last word on every response. If a hook of yours repeats what a hook above it does, that work now happens twice, so remove the repeat. If a hook was added to replace one above it, move the exception into the hook above. After a late hook fails, the late hooks above it still run, on the error. See Every hook on the path runs.
Requires Werkzeug 3.1.7 or newer. The package metadata now says so. It is the oldest release that passes Cylinder’s tests: earlier ones leave the
Accept-Rangesheader off a static file that is sent whole.
Documentation in 0.4.0
Deployment has its own page. The sections on WSGI servers, reverse proxies, ASGI servers, and static files in production moved from Operations to Deployment, and kept their anchors. An old link to one of them now opens the Operations page at the top.
The reverse proxy instructions now work under Waitress. They said to wrap the app in
ProxyFix. Waitress removes the forwarding headers before the app sees them, so under Waitress that had no effect, andrequest.remote_addr,request.scheme, andrequest.hoststayed the proxy’s. Deployment now shows Waitress’s owntrusted_proxysettings. If you followed the earlier instructions with Waitress, switch to them. See Behind a reverse proxy.Deployment explains how to serve many slow requests at once: Waitress starts with 4 threads and 100 connections, how to raise both, and why
connection_limitmust stay at 500 or below on Windows.Deployment explains how to use every core by running a process for each core behind nginx.
Routing and Security describe a webapp directory as code and content in one tree: Python files run, and every other file is served as it is. What is served has not changed.
0.3.3
Fixed in 0.3.3
An error or redirect no longer carries the
ETagof the response it replaced. When a request was aborted after anETaghad been set, most often by a late hook that refused a static file, the error response kept theETagandAccept-Rangesheaders of the file. A browser could store the error page under the file’sETag, and later be told that the page was still current. Both headers are now dropped, asLocationalready was. See What survives an abort.
Documentation in 0.3.3
The late hook examples in Routing no longer apply to errors. The example that gives assets a long
Cache-Controlset it on every response, so an error or a redirect under that directory was stored for a year too. The example for compressed downloads described the error page for a missing file as a gzip file. Both now check the status. If you copied either one, add the check. See Caching and partial downloads.Routing explains what a late hook sees for a static file: the four statuses, and that the answer is chosen before the hook runs.
Conditional and range requests for static files are now listed under Changed in 0.3.0, not Added, because they changed which responses a late hook sees.
Routing explains how Cylinder tells that a static file has changed, and when a changed file can look unchanged.
The package summary shown on PyPI was missing a word.
0.3.2
Fixed in 0.3.2
Request IDs no longer repeat. A generated request ID was made from the time the request arrived, so requests that started in the same instant, in different threads or worker processes, were given the same ID and their log records could not be told apart. The ID is now random. It keeps its form,
req_followed by 13 hexadecimal digits. See Request IDs.An edit is no longer missed when it keeps a handler file’s length. If a handler file was saved twice within one second and the second save left its length unchanged, such as changing a
1to a2, Cylinder kept running the first version. It now runs the second. See Reloading and restarts.
Improved in 0.3.2
Requests are faster. Cylinder compiles a handler file only when the file changes, and still runs it for every request. In a benchmark of small pages, a request took 21% to 26% less time on Linux and 30% to 39% less on Windows. Cylinder no longer writes
__pycache__directories beside handler files.
0.3.1
Fixed in 0.3.1
A failing
500handler runs once. A500error handler that raised an exception, or calledabort(500), was run a second time to answer for its own failure, so anything it did before failing, such as sending an alert, happened twice. The client still gets a plain500, and the traceback is still logged. See Cylinder always answers.
Documentation in 0.3.1
Operations explains how to restart automatically during development when an imported module changes, using Werkzeug’s reloading server.
0.3.0
Changed in 0.3.0
Conditional and range requests for static files. Static files are sent with
ETag,Last-Modified, andAccept-Rangesheaders. A client that already has the file gets a304, and aRangerequest gets a206with that part of the file. A late hook on static files therefore sees304,206, and416responses as well as200, so a hook that checks for200alone no longer applies to all of them. See What a late hook sees for a static file.Headers and cookies survive
abort(). When a request ends inabort(), a redirect, or an uncaught exception, the headers and cookies already set on the response are now kept on the error or redirect response. They used to be dropped. Headers that describe the discarded body, such asContent-Type, and aLocationheader are not kept, and a header the error sets itself is not overridden. If a handler sets a success-only header such asCache-Control: publicand then aborts, that header is now sent with the error. See What survives an abort.No
Content-Encoding: identity. Static files that are not compressed no longer carry this header. Compressed files are served as before, with their compression as theContent-Encoding.Static files are sent with
Cache-Control: no-cache, so browsers check with the server before reusing a cached copy. They used to be sent with no caching headers at all. A late hook can override it.
Fixed in 0.3.0
Exceptions no longer escape to the WSGI server. Three cases used to: a late hook that raised after an
abort()or a redirect, an error handler that calledabort()with a status other than500, and an exception inapp_map(). Cylinder now answers all of them itself and logs the cause. As a result,abort()can be used in an error handler and inapp_map(), and cleanup registered inapp_map()runs even if it raises afterwards. See Cylinder always answers.Drive letters in a URL on Windows. A path segment such as
D:foocaused a500, and a segment such asC:foowas treated asfoo. Both are now ordinary segments on every operating system.
Documentation in 0.3.0
The documentation is reorganized into separate pages, with new pages for JSON APIs, security, and a reference.
A skill file for AI coding assistants is published with the documentation.
A new page covers large applications: why the model scales, how to lay out a big project, and the limits.
Operations explains how to run under an ASGI server, alone or beside async code.
0.2.3
Added in 0.2.3
remainderparameter. Handlers can ask for the URL path segments left over after their file was matched, so they no longer need to count segments ofrequest.path. See Accessing the remaining path.HEADrequests work without code. AHEADrequest runs the.getfiles and the body is dropped. A.headfile still takes precedence. See HEAD requests.Returning a string. A handler can return a
strorbytes, which becomes the response body. See Returning a string as a shorthand.Default values for parameters. A handler parameter with a default value keeps its default when Cylinder has nothing to pass for it.
Changed in 0.2.3
Unknown parameters are an error. A handler, hook, or
app_map()that asks for a parameter Cylinder cannot supply now raisesTypeError. It used to receiveNone. Give the parameter a default value if it is optional.HEADrouting. At a path with both a.getand a.defaultfile,HEADnow runs the.getfile. It used to run.default..gethooks now run forHEADrequests as well.Static files. Paths with a segment that starts with a dot, and files whose names contain
.pyin any letter case, are no longer served. See What is never served.eis always available. It isNonewhen no exception has been raised. It used to be available only after an exception.The error for a wrong return value has new wording and reports the type that was returned.
A built-in parameter named
remaindernow takes precedence over an extra parameter of the same name fromapp_map().Requires Python 3.10 or newer. The package metadata now says so. Earlier versions were never able to run it.
License metadata corrected to Apache-2.0, matching the license file.
Fixed in 0.2.3
Cleanup callbacks. Functions registered with
response.call_on_close()were not called when a request ended inabort(), a redirect, or an uncaught exception. They now run however the request ends.Decorated handlers. A
main()wrapped by a decorator that usesfunctools.wrapsnow receives its parameters.Webapp directory. A
site_dirthat contains.., is reached through a symbolic link, or differs in letter case from the working directory no longer causes every request to return501..path segments in a URL are now ignored, as..and empty segments already were.
0.2.2
Static files are read and sent in chunks, so a large file is no longer loaded into memory.
Earlier releases
See the releases page on GitHub.