summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-09-23 20:13:23 -0400
committerChris McDonough <chrism@plope.com>2011-09-23 20:13:23 -0400
commit5e21d5cefc4b7441e84f1412af3556a395f13489 (patch)
treebb25681e92b7fa12fca2a13c18345cb2595399a8
parent9549997d246ff0428c72609951ebcb70056cedc4 (diff)
downloadpyramid-5e21d5cefc4b7441e84f1412af3556a395f13489.tar.gz
pyramid-5e21d5cefc4b7441e84f1412af3556a395f13489.tar.bz2
pyramid-5e21d5cefc4b7441e84f1412af3556a395f13489.zip
whats the safe word
-rw-r--r--pyramid/config/util.py23
-rw-r--r--pyramid/scaffolds/__init__.py4
-rw-r--r--pyramid/tests/test_integration.py4
3 files changed, 16 insertions, 15 deletions
diff --git a/pyramid/config/util.py b/pyramid/config/util.py
index 7980a78e3..0b3d14f07 100644
--- a/pyramid/config/util.py
+++ b/pyramid/config/util.py
@@ -95,7 +95,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
xhr_predicate.__text__ = "xhr = True"
weights.append(1 << 1)
predicates.append(xhr_predicate)
- h.update('xhr:%r' % bool(xhr))
+ h.update(bytes_('xhr:%r' % bool(xhr)))
if request_method is not None:
if not hasattr(request_method, '__iter__'):
@@ -108,7 +108,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
weights.append(1 << 2)
predicates.append(request_method_predicate)
for m in request_method:
- h.update('request_method:%r' % m)
+ h.update(bytes_('request_method:%r' % m))
if path_info is not None:
try:
@@ -121,7 +121,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
path_info_predicate.__text__ = text % path_info
weights.append(1 << 3)
predicates.append(path_info_predicate)
- h.update('path_info:%r' % path_info)
+ h.update(bytes_('path_info:%r' % path_info))
if request_param is not None:
request_param_val = None
@@ -138,7 +138,8 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
request_param_predicate.__text__ = text
weights.append(1 << 4)
predicates.append(request_param_predicate)
- h.update('request_param:%r=%r' % (request_param, request_param_val))
+ h.update(
+ bytes_('request_param:%r=%r' % (request_param, request_param_val)))
if header is not None:
header_name = header
@@ -163,7 +164,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
header_predicate.__text__ = text
weights.append(1 << 5)
predicates.append(header_predicate)
- h.update('header:%r=%r' % (header_name, header_val))
+ h.update(bytes_('header:%r=%r' % (header_name, header_val)))
if accept is not None:
def accept_predicate(context, request):
@@ -171,7 +172,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
accept_predicate.__text__ = "accept = %s" % accept
weights.append(1 << 6)
predicates.append(accept_predicate)
- h.update('accept:%r' % accept)
+ h.update(bytes_('accept:%r' % accept))
if containment is not None:
def containment_predicate(context, request):
@@ -179,7 +180,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
containment_predicate.__text__ = "containment = %s" % containment
weights.append(1 << 7)
predicates.append(containment_predicate)
- h.update('containment:%r' % hash_(containment))
+ h.update(bytes_('containment:%r' % containment))
if request_type is not None:
def request_type_predicate(context, request):
@@ -188,7 +189,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
request_type_predicate.__text__ = text % request_type
weights.append(1 << 8)
predicates.append(request_type_predicate)
- h.update('request_type:%r' % hash_(request_type))
+ h.update(bytes_('request_type:%r' % request_type))
if match_param is not None:
if isinstance(match_param, string_types):
@@ -203,7 +204,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
match_param_predicate.__text__ = text
weights.append(1 << 9)
predicates.append(match_param_predicate)
- h.update('match_param:%r' % match_param)
+ h.update(bytes_('match_param:%r' % match_param))
if custom:
for num, predicate in enumerate(custom):
@@ -224,7 +225,7 @@ def make_predicates(xhr=None, request_method=None, path_info=None,
# 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)))
+ h.update(bytes_('custom%s:%r' % (num, predicate)))
weights.append(1 << 10)
if traverse is not None:
@@ -261,5 +262,3 @@ def as_sorted_tuple(val):
val = tuple(sorted(val))
return val
-def hash_(v):
- return bytes_(hash(v))
diff --git a/pyramid/scaffolds/__init__.py b/pyramid/scaffolds/__init__.py
index 1595c37eb..673f22e21 100644
--- a/pyramid/scaffolds/__init__.py
+++ b/pyramid/scaffolds/__init__.py
@@ -1,5 +1,7 @@
import os
+from pyramid.compat import print_
+
try:
from paste.script.templates import Template
except ImportError: # pragma: no cover
@@ -27,7 +29,7 @@ class PyramidTemplate(Template):
return Template.post(self, command, output_dir, vars)
def out(self, msg): # pragma: no cover (replaceable testing hook)
- print msg
+ print_(msg)
class StarterProjectTemplate(PyramidTemplate):
_template_dir = 'starter'
diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py
index 9db03c28b..3c970e3bc 100644
--- a/pyramid/tests/test_integration.py
+++ b/pyramid/tests/test_integration.py
@@ -65,7 +65,7 @@ here = os.path.dirname(__file__)
class TestStaticAppBase(IntegrationBase):
def _assertBody(self, body, filename):
self.assertEqual(
- body.replace('\r', ''),
+ body.replace(b'\r', b''),
open(filename, 'rb').read()
)
@@ -206,7 +206,7 @@ class TestStaticAppWithRoutePrefix(IntegrationBase, unittest.TestCase):
package = 'pyramid.tests.pkgs.static_routeprefix'
def _assertBody(self, body, filename):
self.assertEqual(
- body.replace('\r', ''),
+ body.replace(b'\r', b''),
open(filename, 'rb').read()
)