Skip to content

Commit

Permalink
Merge pull request #9 from kpy21ui/bugfix/environ-vars-for-sentry
Browse files Browse the repository at this point in the history
Fix environ vars
  • Loading branch information
tumb1er authored Jul 31, 2020
2 parents 066f2dd + efc02d2 commit 0b4508e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ You may run sitemap generation from celery:
```python
@celery.task
def generate_sitemap():
generator = SitemapGenerator(sitemaps={'video': VideoSitema[})
generator = SitemapGenerator(sitemaps={'video': VideoSitemap)
generator.generate()
```

Expand Down
2 changes: 1 addition & 1 deletion sitemap_generate/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Hostname used in sitemap links
SITEMAP_HOST = e('SITEMAP_HOST', 'localhost')
# Port used in sitemap links
SITEMAP_PORT = int(e('SITEMAP_PORT', 443))
SITEMAP_PORT = e('SITEMAP_PORT', '443')
# Protocol used in sitemap links
SITEMAP_PROTO = e('SITEMAP_PROTO', 'https')
11 changes: 10 additions & 1 deletion sitemap_generate/generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from io import StringIO
from logging import getLogger
from typing import Dict, Optional, Callable, Type
from urllib.parse import ParseResult, urlparse
Expand Down Expand Up @@ -49,7 +50,15 @@ def record(self, url: str) -> bytes:

environ = {
'REQUEST_METHOD': 'GET',
'wsgi.input': '',
'wsgi.errors': StringIO(),
'wsgi.input': StringIO(),
'wsgi.version': (1, 0),
'wsgi.multithread': False,
'wsgi.multiprocess': False,
'wsgi.run_once': False,
'wsgi.url_scheme': defaults.SITEMAP_PROTO,
'SCRIPT_NAME': '',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_NAME': defaults.SITEMAP_HOST,
'SERVER_PORT': defaults.SITEMAP_PORT,
'PATH_INFO': url.path,
Expand Down
2 changes: 1 addition & 1 deletion testproject/testapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_generate_sitemap(self):
scheme = defaults.SITEMAP_PROTO
host = defaults.SITEMAP_HOST
port = defaults.SITEMAP_PORT
if (scheme, port) in [('https', 443), ('http', 80)]:
if (scheme, port) in [('https', '443'), ('http', '80')]:
netloc = host
else:
netloc = f'{host}:{port}'
Expand Down

0 comments on commit 0b4508e

Please sign in to comment.