summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/rest/docs/helpers.rst4
-rw-r--r--src/mailman/rest/docs/preferences.rst2
-rw-r--r--src/mailman/rest/helpers.py7
-rw-r--r--src/mailman/rest/wsgiapp.py3
-rw-r--r--tox.ini12
5 files changed, 21 insertions, 7 deletions
diff --git a/src/mailman/rest/docs/helpers.rst b/src/mailman/rest/docs/helpers.rst
index 68dfda1be..5bcf5cad4 100644
--- a/src/mailman/rest/docs/helpers.rst
+++ b/src/mailman/rest/docs/helpers.rst
@@ -45,7 +45,7 @@ gets modified to contain the etag under the ``http_etag`` key.
>>> resource = dict(geddy='bass', alex='guitar', neil='drums')
>>> json_data = etag(resource)
>>> print(resource['http_etag'])
- "43942176d8d5bb4414ccf35e2720ccd5251e66da"
+ "96e036d66248cab746b7d97047e08896fcfb2493"
For convenience, the etag function also returns the JSON representation of the
dictionary after tagging, since that's almost always what you want.
@@ -58,7 +58,7 @@ dictionary after tagging, since that's almost always what you want.
>>> dump_msgdata(data)
alex : guitar
geddy : bass
- http_etag: "43942176d8d5bb4414ccf35e2720ccd5251e66da"
+ http_etag: "96e036d66248cab746b7d97047e08896fcfb2493"
neil : drums
diff --git a/src/mailman/rest/docs/preferences.rst b/src/mailman/rest/docs/preferences.rst
index b8a0af500..b9332c954 100644
--- a/src/mailman/rest/docs/preferences.rst
+++ b/src/mailman/rest/docs/preferences.rst
@@ -162,7 +162,7 @@ deleted.
>>> dump_json('http://localhost:9001/3.0/addresses/anne@example.com'
... '/preferences')
acknowledge_posts: True
- http_etag: "5219245d1eea98bc107032013af20ef91bfb5c51"
+ http_etag: "1ff07b0367bede79ade27d217e12df3915aaee2b"
preferred_language: ja
self_link: http://localhost:9001/3.0/addresses/anne@example.com/preferences
diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py
index acc5106be..f67d9d448 100644
--- a/src/mailman/rest/helpers.py
+++ b/src/mailman/rest/helpers.py
@@ -46,6 +46,7 @@ from datetime import datetime, timedelta
from enum import Enum
from lazr.config import as_boolean
from mailman.config import config
+from pprint import pformat
@@ -103,8 +104,10 @@ def etag(resource):
:rtype string
"""
assert 'http_etag' not in resource, 'Resource already etagged'
- etag = hashlib.sha1(repr(resource)).hexdigest()
-
+ # Calculate the tag from a predictable (i.e. sorted) representation of the
+ # dictionary. The actual details aren't so important. pformat() is
+ # guaranteed to sort the keys.
+ etag = hashlib.sha1(pformat(resource)).hexdigest()
resource['http_etag'] = '"{0}"'.format(etag)
return json.dumps(resource, cls=ExtendedEncoder)
diff --git a/src/mailman/rest/wsgiapp.py b/src/mailman/rest/wsgiapp.py
index d95926cfd..82f2a3a8f 100644
--- a/src/mailman/rest/wsgiapp.py
+++ b/src/mailman/rest/wsgiapp.py
@@ -30,7 +30,6 @@ import re
import logging
from falcon import API
-from falcon.api_helpers import create_http_method_map
from falcon.responders import path_not_found
from mailman.config import config
from mailman.database.transaction import transactional
@@ -132,7 +131,7 @@ class RootedAPI(API):
if len(path_segments) == 0:
# We're at the end of the path, so the root must be the
# responder.
- method_map = create_http_method_map(
+ method_map = self._create_http_method_map(
resource, None, None, None)
responder = method_map[method]
return responder, {}, resource
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 000000000..881c90136
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,12 @@
+[tox]
+envlist = py27
+recreate = True
+
+[testenv]
+commands = python -m nose2 -v
+#sitepackages = True
+usedevelop = True
+deps =
+ git+https://github.com/racker/falcon.git#egg=falcon
+setenv =
+ PYTHONHASHSEED=100