Skip to content

Fix local detection of Dexterity @@images resources in Impress url_fetcher - #169

Open
Lunga001 wants to merge 1 commit into
senaite:2.xfrom
bikalims:lab-accred-pdf-view
Open

Fix local detection of Dexterity @@images resources in Impress url_fetcher#169
Lunga001 wants to merge 1 commit into
senaite:2.xfrom
bikalims:lab-accred-pdf-view

Conversation

@Lunga001

Copy link
Copy Markdown

Description of the issue/feature this PR addresses

Linked issue: #168
Fixes the detection of local Dexterity image resources when rendering PDFs.

Browser views such as @@images resolve the image field segment dynamically,
therefore traversing the complete image URL may return None even though the
resource belongs to the current Plone site.

This causes the publisher to incorrectly delegate image loading to
default_url_fetcher(), resulting in external HTTP requests and connection
timeouts.

Current behavior before PR

The image is classified as an external resource and fetched with
default_url_fetcher().
Typical log output:
context=None
External URL, delegate to default URL fetcher...

The PDF generation waits for the external connection timeout before continuing.

Desired behavior after PR is merged

Dexterity @@images resources should be treated as local resources and fetched
through an authenticated subrequest, just like other Plone resources.

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

Treat @@images URLs as local resources by traversing to their owning
content object. The @@images browser view handles image field paths
dynamically, so traversing the complete URL can return None and cause
the publisher to incorrectly fetch the image externally.

Continue using the complete image path for the authenticated subrequest
and use the response Content-Type when available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant