Python: Add from workers import env for top level env#5682
Merged
Conversation
danlapid
approved these changes
Dec 12, 2025
Collaborator
danlapid
left a comment
There was a problem hiding this comment.
Why the hell did I not think of this myself?
ryanking13
approved these changes
Dec 12, 2025
jasnell
approved these changes
Dec 12, 2025
G4brym
pushed a commit
to G4brym/django-cf
that referenced
this pull request
Feb 20, 2026
…t("cloudflare:workers")`
Replaces the old pattern of using import_from_javascript to dynamically
import the cloudflare:workers module with the new direct `from workers
import env` syntax added in workerd (cloudflare/workerd#5682).
This simplifies env access in the D1 backend and R2 storage, removing
the need to store import_from_javascript as an instance attribute.
Closes #28
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 7, 2026
…udflare:workers")`
Replace the indirect `import_from_javascript("cloudflare:workers")` pattern
with the direct `from workers import env` import in both the D1 database
backend and R2 storage backend. This uses the newer Workers Python API
(cloudflare/workerd#5682) which is cleaner and avoids the JavaScript
interop layer for accessing environment bindings.
Fixes #28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 7, 2026
…udflare:workers")`
Replace the indirect `import_from_javascript("cloudflare:workers")` pattern with the
direct `from workers import env` import, as supported by the workers runtime
(see cloudflare/workerd#5682). This simplifies the code by removing the
intermediate JavaScript module import step.
Updated both D1 database backend and R2 storage backend, along with their tests.
Fixes #28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 7, 2026
…dflare:workers")
Replace the indirect `import_from_javascript("cloudflare:workers")` pattern with
the cleaner `from workers import env` in both the D1 database backend and R2
storage backend. This uses the newer workers module API (cloudflare/workerd#5682).
Fixes #28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 9, 2026
…udflare:workers")`
Replace the indirect `import_from_javascript("cloudflare:workers")` pattern
with the direct `from workers import env` import in both the D1 database
backend and R2 storage backend. This uses the newer Workers Python API
(cloudflare/workerd#5682) which is cleaner and avoids the JavaScript
interop layer for accessing environment bindings.
Fixes #28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 9, 2026
…udflare:workers")`
Replace the indirect `import_from_javascript("cloudflare:workers")` pattern with the
direct `from workers import env` import, as supported by the workers runtime
(see cloudflare/workerd#5682). This simplifies the code by removing the
intermediate JavaScript module import step.
Updated both D1 database backend and R2 storage backend, along with their tests.
Fixes #28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 9, 2026
…rkers (#32) * Use `from workers import env` instead of `import_from_javascript("cloudflare:workers")` Replace the indirect `import_from_javascript("cloudflare:workers")` pattern with the direct `from workers import env` import in both the D1 database backend and R2 storage backend. This uses the newer Workers Python API (cloudflare/workerd#5682) which is cleaner and avoids the JavaScript interop layer for accessing environment bindings. Fixes #28 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix CI: remove import_from_javascript references from tests and bump compat date - Remove all _import_from_javascript references from test_storage_errors.py and test_d1_backend.py since this attribute was removed in the workers env import migration - Bump wrangler compatibility_date from 2025-11-25 to 2026-03-08 in all wrangler.jsonc files (tests/servers/r2, templates/d1, templates/durable-objects) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Bump wrangler to ^4.71.0 to support `from workers import env` Wrangler 4.51.0's bundled workerd runtime only supports compat dates up to 2025-11-25, which predates the `from workers import env` API. Upgrading to wrangler 4.71.0 brings a newer workerd that supports the 2026-03-08 compat date and the direct env import. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Update pnpm-lock.yaml for wrangler 4.71.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
G4brym
added a commit
to G4brym/django-cf
that referenced
this pull request
Mar 9, 2026
…dflare:workers")
Replace the indirect `import_from_javascript("cloudflare:workers")` pattern with
the cleaner `from workers import env` in both the D1 database backend and R2
storage backend. This uses the newer workers module API (cloudflare/workerd#5682).
Fixes #28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
No description provided.