Repository navigation
Conversation
…go URLs from it Building an application was spread over find_package_routes in urls.py, the setup() functions of winter.web, winter.django and winter.openapi, and set_injector. Their order was manual: setup() saw only the classes imported by then, so a @problem exception could silently get no handler. Application imports every module of the given packages on construction (by default, those of the directory of the module that creates it) and holds their classes and functions as its definitions, plus whatever is added with app.add(). Several applications may share one injector. winter.django.create_urls(app) builds the URL patterns from it, and winter.openapi gets generate_openapi(app, ...), serve_spec and serve_swagger_ui; the served spec and Swagger UI work under whatever prefix the application is included at. The behavioural registries are still process-global: the isolation test is rewritten on observable behaviour and stays xfail. BREAKING CHANGE: WinterApplication, find_package_routes, create_django_urls_from_routes and the setup() functions of winter.web, winter.django and winter.openapi are removed. A @problem exception gets its handler only when it belongs to an application. generate_openapi takes an Application instead of routes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The adapters initialise winter.web, the Django adapter and winter.openapi once per process. The architecture document now lists this as a deviation and describes the target: each Application owns these registries in a child injector, adapters add their entries to that application only, and the initialize functions disappear. Each of them points to that deviation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lic API Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building an application was spread over three places:
find_package_routesinurls.py, thesetup()functions ofwinter.web,winter.djangoandwinter.openapi, andset_injector. Their order was kept by hand:setup()saw only the classes imported by then, so a@problemexception could silently get no handler.winter.application.Applicationcollects this into one object that adapters build from:__init__.pyis not a package and is skipped. A module that fails to import fails the constructor, with a note saying why it was imported. By default the modules are those of the directory of the module that creates the Application. Underpython -mthe creating module is not imported a second time.app.add()adds, such as generated code or a class defined elsewhere:app.add(winter.web.problem(status=404)(NotFoundException)).winter.django.create_urls(app)initialiseswinter.weband the Django adapter once per process, registers the handlers of the application's@problemexceptions, and returns URL patterns relative to where they are included.generate_openapi(app, title=..., version=...)returns the spec as a dict, with no endpoint, and checks the@raisesannotations of the application.serve_spec(app, spec, url=...)andserve_swagger_ui(app, spec_url=..., url=...)add the routes that serve them; the docs routes are not part of the spec. The served spec getsserversprefixed with the path the application is mounted at, computed per request, so it is correct underinclude('service_b/', ...).@problemhandler of one application must not handle that exception in another. It staysxfailwhile handler registries are process-global.Breaking:
WinterApplication,find_package_routes,create_django_urls_from_routesand allsetup()functions are removed; README has an "Upgrading to Winter 34" section. Other behaviour changes to check when migrating:create_urlsinstalls the Django throttling identity on its first call, so a custom resolver goes after it.This PR targets
v34. The 34.0 work, moving the behavioural registries intoApplication, lands there in small PRs and is released once, whenv34merges intomaster; until then the consumer can try it from the branch.winter.wsgiand the getting-started switch come after.🤖 Generated with Claude Code