diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-09-07 20:27:17 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-09-07 20:27:17 +0000 |
| commit | a58c4a4968053314be39aae62eed3c7a9c863e40 (patch) | |
| tree | b3bb42fa59ed926e10a9e81cdd57734afb81fe66 /repoze/bfg/configuration.py | |
| parent | 6b9e366a4d6d0ac6a0424646e3d2ba32850371b8 (diff) | |
| download | pyramid-a58c4a4968053314be39aae62eed3c7a9c863e40.tar.gz pyramid-a58c4a4968053314be39aae62eed3c7a9c863e40.tar.bz2 pyramid-a58c4a4968053314be39aae62eed3c7a9c863e40.zip | |
- Use ``hash()`` rather than ``id()`` when computing the "phash" of a
custom route/view predicate in order to allow the custom predicate
some control over which predicates are "equal".
- Use ``response.headerlist.append`` instead of
``response.headers.add`` in
``repoze.bfg.request.add_global_response_headers`` in case the
response is not a WebOb response.
Diffstat (limited to 'repoze/bfg/configuration.py')
| -rw-r--r-- | repoze/bfg/configuration.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index c5ae995e5..488761ec4 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -1982,14 +1982,14 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, return find_interface(context, containment) is not None weights.append(1 << 7) predicates.append(containment_predicate) - h.update('containment:%r' % id(containment)) + h.update('containment:%r' % hash(containment)) if request_type is not None: def request_type_predicate(context, request): return request_type.providedBy(request) weights.append(1 << 8) predicates.append(request_type_predicate) - h.update('request_type:%r' % id(request_type)) + h.update('request_type:%r' % hash(request_type)) if traverse is not None: # ``traverse`` can only be used as a *route* "predicate"; it @@ -2014,7 +2014,13 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, if custom: for num, predicate in enumerate(custom): predicates.append(predicate) - h.update('custom%s:%r' % (num, id(predicate))) + # using hash() here rather than id() is intentional: we + # want to allow custom predicates that are part of + # frameworks to be able to define custom __hash__ + # functions for custom predicates, so that the hash output + # of predicate instances which are "logically the same" + # may compare equal. + h.update('custom%s:%r' % (num, hash(predicate))) weights.append(1 << 10) score = 0 |
