diff options
| author | Barry Warsaw | 2014-11-06 20:39:25 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2014-11-06 20:39:25 -0500 |
| commit | 59f980abc3aa10e0ff8a3d38ed91d69f68b194ed (patch) | |
| tree | d5a63195a5dbe702cf6b8c0c51f474cae8b0e2c0 /src/mailman/rest/helpers.py | |
| parent | 9b19d1a9d77e71afc0783f22496bd623eda3024b (diff) | |
| download | mailman-59f980abc3aa10e0ff8a3d38ed91d69f68b194ed.tar.gz mailman-59f980abc3aa10e0ff8a3d38ed91d69f68b194ed.tar.zst mailman-59f980abc3aa10e0ff8a3d38ed91d69f68b194ed.zip | |
Diffstat (limited to 'src/mailman/rest/helpers.py')
| -rw-r--r-- | src/mailman/rest/helpers.py | 7 |
1 files changed, 5 insertions, 2 deletions
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) |
