From 69626ce4531664532870c950f4c1d66a0830a50a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 23 Sep 2009 02:32:34 +0000 Subject: - On 64-bit Linux systems, views that were members of a multiview (orderings of views with predicates) were not evaluated in the proper order. Symptom: in a configuration that had two views with the same name but one with a ``request_method=POST`` predicate and one without, the one without the predicate would be called unconditionally (even if the request was a POST request). Thanks much to Sebastien Douche for providing the buildbots that pointed this out. --- CHANGES.txt | 12 ++++++++++++ repoze/bfg/zcml.py | 8 +++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e6b44519c..ed4dd29ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,18 @@ Next release ============ +Bug Fixes +--------- + +- On 64-bit Linux systems, views that were members of a multiview + (orderings of views with predicates) were not evaluated in the + proper order. Symptom: in a configuration that had two views with + the same name but one with a ``request_method=POST`` predicate and + one without, the one without the predicate would be called + unconditionally (even if the request was a POST request). Thanks + much to Sebastien Douche for providing the buildbots that pointed + this out. + Documentation ------------- diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 72b39fcb3..3faadb24b 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -194,7 +194,7 @@ def view( # share the same number of predicates. # Views which do not have any predicates get a score of - # "sys.maxint", meaning that they will be tried very last. + # sys.maxint, meaning that they will be tried very last. if request_method is not None: def request_method_predicate(context, request): @@ -219,10 +219,8 @@ def view( weight = weight - 30 predicates.append(containment_predicate) - if predicates: - score = float(weight) / len(predicates) - else: - score = sys.maxint + # this will be == sys.maxint if no predicates + score = weight / (len(predicates) + 1) if renderer and '.' in renderer: renderer = resource_spec(renderer, package_name(_context.resolve('.'))) -- cgit v1.2.3