Skip to content

Python: Add from workers import env for top level env#5682

Merged
hoodmane merged 1 commit intomainfrom
hoodmane/python-workers-env
Dec 12, 2025
Merged

Python: Add from workers import env for top level env#5682
hoodmane merged 1 commit intomainfrom
hoodmane/python-workers-env

Conversation

@hoodmane
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Collaborator

@danlapid danlapid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the hell did I not think of this myself?

@hoodmane hoodmane merged commit 0771b31 into main Dec 12, 2025
31 of 33 checks passed
@hoodmane hoodmane deleted the hoodmane/python-workers-env branch December 12, 2025 17:53
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>
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>
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants