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, and late. 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 a 404 until a handler serves it. For each directory of files for the browser, add <directory>.tree.get.py beside it, with the one line from cylinder import static_file as main. For a single file such as robots.txt, add robots.txt.page.get.py beside 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 a 405, as it does at any other page. And a handler of your own can call static_file and 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 404 or a 405, and no longer a 501. A request with any method but GET and HEAD that no page handler served got 501 Not Implemented, whether or not anything was at the URL. A 501 is a server error, so a POST to 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 a 404 Not Found, whatever the method. If it has one for other methods, it is a 405 Method Not Allowed, and the Allow header lists the methods that have a file. GET is no exception: a GET to a URL that has only a .post file used to get a 404, and now gets a 405. A method that no file can be named for still gets a 501. If a site has an error handler file for 501, name it for 405, and check that its 404 handler 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 .default page handler that only calls abort(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 INFO level and 33 percent faster at DEBUG. 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, and cylinder.log_queue_length are gone, and so is the rule that the oldest waiting records are dropped when the queue is full. Remove app.wait_for_logs = True from your tests: there is nothing left to wait for. If your log_handler is 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 .default file for each resource to refuse other methods, because the 405 now 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_file from 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 for remainder, so a parameter decided routing. The filename decides it now, like everything else about a route: files.tree.get.py serves /files and every path beneath it that has no closer match, and files.ex.get.py serves /files only. Rename every page handler that serves deeper paths from <name>.ex.<method>.py to <name>.tree.<method>.py. They are the page handlers that have remainder among their parameters. One that is not renamed serves its own path only: the URLs beneath it get a 404, or a 501 for a method other than GET and HEAD, and its remainder is always []. remainder is 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}, where name is 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 /admin did not apply to //admin or /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 for 404, or for 501 when the method is not GET or HEAD. 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.RedirectFound and the four classes like it are gone. cylinder.HTTPRedirect, which every redirect is an instance of, is unchanged, and e.code says 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 500 handler aborts with is final, whatever it is answering for. When an error handler raised an exception and the 500 handler then redirected or aborted with another status, the client got a plain 500. It now gets what the 500 handler 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.py handles /users/123, and main() can ask for user_id, which is "123". A placeholder stands for exactly one segment, so /users/123/extra is a 404 without 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

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 remainder still 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 /USERS was answered by users.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 compares request.path with 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 in app_map() was in the wrong case and worked on macOS, it now gets a 404 there, 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 as M-SEARCH, or is the reserved DEFAULT, used to get a 500 and a logged traceback, so a client could set off a site’s 500 handler at will. It is now turned down like any other request that no page handler serves: the .default hooks run, and the error handler for 501 answers. 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/456 is better served as /posts/456, with relationships such as /posts?user=123 in 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 returned 200 unless the handler checked remainder and called abort(404). A handler without remainder in 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 for remainder behaves as before. If a handler of yours answers for deeper paths without asking, for example a root handler that looks at request.path, add remainder to its parameters. A check such as if remainder: abort(404) in a handler that takes no dynamic segments can be removed, together with the parameter. See Dynamic paths.

  • A GET or HEAD that no page handler serves gets 404 Not Found. It used to get 501 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 404 does, and the headers and cookies an early hook sets are on the 404 or 501 response.

  • 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-Ranges header 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, and request.remote_addr, request.scheme, and request.host stayed the proxy’s. Deployment now shows Waitress’s own trusted_proxy settings. 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_limit must 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 ETag of the response it replaced. When a request was aborted after an ETag had been set, most often by a late hook that refused a static file, the error response kept the ETag and Accept-Ranges headers of the file. A browser could store the error page under the file’s ETag, and later be told that the page was still current. Both headers are now dropped, as Location already 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-Control set 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 1 to a 2, 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 500 handler runs once. A 500 error handler that raised an exception, or called abort(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 plain 500, and the traceback is still logged. See Cylinder always answers.

Documentation in 0.3.1

0.3.0

Changed in 0.3.0

  • Conditional and range requests for static files. Static files are sent with ETag, Last-Modified, and Accept-Ranges headers. A client that already has the file gets a 304, and a Range request gets a 206 with that part of the file. A late hook on static files therefore sees 304, 206, and 416 responses as well as 200, so a hook that checks for 200 alone 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 in abort(), 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 as Content-Type, and a Location header are not kept, and a header the error sets itself is not overridden. If a handler sets a success-only header such as Cache-Control: public and 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 the Content-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 called abort() with a status other than 500, and an exception in app_map(). Cylinder now answers all of them itself and logs the cause. As a result, abort() can be used in an error handler and in app_map(), and cleanup registered in app_map() runs even if it raises afterwards. See Cylinder always answers.

  • Drive letters in a URL on Windows. A path segment such as D:foo caused a 500, and a segment such as C:foo was treated as foo. Both are now ordinary segments on every operating system.

Documentation in 0.3.0

0.2.3

Added in 0.2.3

  • remainder parameter. Handlers can ask for the URL path segments left over after their file was matched, so they no longer need to count segments of request.path. See Accessing the remaining path.

  • HEAD requests work without code. A HEAD request runs the .get files and the body is dropped. A .head file still takes precedence. See HEAD requests.

  • Returning a string. A handler can return a str or bytes, 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 raises TypeError. It used to receive None. Give the parameter a default value if it is optional.

  • HEAD routing. At a path with both a .get and a .default file, HEAD now runs the .get file. It used to run .default. .get hooks now run for HEAD requests as well.

  • Static files. Paths with a segment that starts with a dot, and files whose names contain .py in any letter case, are no longer served. See What is never served.

  • e is always available. It is None when 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 remainder now takes precedence over an extra parameter of the same name from app_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 in abort(), a redirect, or an uncaught exception. They now run however the request ends.

  • Decorated handlers. A main() wrapped by a decorator that uses functools.wraps now receives its parameters.

  • Webapp directory. A site_dir that contains .., is reached through a symbolic link, or differs in letter case from the working directory no longer causes every request to return 501.

  • . 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.