collective / collective/collective.taskqueue

Keep SERVER_URL header

Open
#20 4 comments 0 reactions 0 assignees View on GitHub
bug question
Dominant language
Python
Stars
7
Forks
7
PR merge metrics
No merged PRs in 30d

Description

`collective.taskqueue` [saves some headers](https://github.com/collective/collective.taskqueue/blob/master/src/collective/taskqueue/taskqueue.py#L135) 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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.