Skip to content

Keep SERVER_URL header #20

Description

@gforcada

collective.taskqueue saves some headers on the request that queues a job so that later triggering the view that is being queued is as close as possible to the original request.

I found a strange error though, the event handler that queues the view reports:

(Pdb) from zope.globalrequest import getRequest
(Pdb) getRequest()['SERVER_URL']
'https://www.devtest.freitag-verlag.de'

While the view that got queued then reports:

(Pdb) from zope.globalrequest import getRequest
(Pdb) getRequest()['SERVER_URL']
'http://10.100.0.205'

I noticed that because on one of the async views that I have I'm sending emails and on its body I put the URL of an article, and instead of being https://www.freitag.de/autoren/der-freitag/RANDOM-ARTCILE is https://www.freitag.de/website/autoren/der-freitag/RANDOM-ARTCILE, notice the website on it, that's the Plone instance id. I'm just getting an object and calling its absolute_url method (that's a Dexterity Container that ends up calling HTTPRequest.physicalPathFromURL and puts the SERVER_URL).

I tried forcing the header by putting it while queuing the job, i.e

taskqueue.add(view_path, headers={'SERVER_URL': getRequest()['SERVER_URL']})

But somehow even though the header is saved correctly, when the task is picked up again it's discarded and http://10.100.0.205 shows up again.

@datakurre am I doing something wrong or that's a valid bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions