diff options
| author | cguardia <carlos.delaguardia@gmail.com> | 2011-04-27 00:52:30 -0500 |
|---|---|---|
| committer | cguardia <carlos.delaguardia@gmail.com> | 2011-04-27 00:52:30 -0500 |
| commit | 3080ffd838ca3c163b3aeb35b63a774bcddedb92 (patch) | |
| tree | e55dacc4c2ddb97ab3ebc17cdbb5a004b756afd3 | |
| parent | f6ac0d31976b14a67873c3c97d8e084902e5740a (diff) | |
| download | pyramid-3080ffd838ca3c163b3aeb35b63a774bcddedb92.tar.gz pyramid-3080ffd838ca3c163b3aeb35b63a774bcddedb92.tar.bz2 pyramid-3080ffd838ca3c163b3aeb35b63a774bcddedb92.zip | |
use __doc__ instead of __text__ for predicate description
| -rw-r--r-- | pyramid/config.py | 24 | ||||
| -rw-r--r-- | pyramid/paster.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_config.py | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/pyramid/config.py b/pyramid/config.py index a24392302..5008e42fb 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -2486,7 +2486,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, if xhr: def xhr_predicate(context, request): return request.is_xhr - xhr_predicate.__text__ = "xhr = True" + xhr_predicate.__doc__ = "xhr = True" weights.append(1 << 1) predicates.append(xhr_predicate) h.update('xhr:%r' % bool(xhr)) @@ -2495,7 +2495,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, def request_method_predicate(context, request): return request.method == request_method msg = "request method = %s" - request_method_predicate.__text__ = msg % request_method + request_method_predicate.__doc__ = msg % request_method weights.append(1 << 2) predicates.append(request_method_predicate) h.update('request_method:%r' % request_method) @@ -2508,7 +2508,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, def path_info_predicate(context, request): return path_info_val.match(request.path_info) is not None msg = "path_info = %s" - path_info_predicate.__text__ = msg % path_info + path_info_predicate.__doc__ = msg % path_info weights.append(1 << 3) predicates.append(path_info_predicate) h.update('path_info:%r' % path_info) @@ -2525,7 +2525,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, msg = "request_param %s" % request_param else: msg = "request_param %s = %s" % (request_param, request_param_val) - request_param_predicate.__text__ = msg + request_param_predicate.__doc__ = msg weights.append(1 << 4) predicates.append(request_param_predicate) h.update('request_param:%r=%r' % (request_param, request_param_val)) @@ -2550,7 +2550,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, msg = "header %s" % header_name else: msg = "header %s = %s" % (header_name, header_val) - header_predicate.__text__ = msg + header_predicate.__doc__ = msg weights.append(1 << 5) predicates.append(header_predicate) h.update('header:%r=%r' % (header_name, header_val)) @@ -2558,7 +2558,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, if accept is not None: def accept_predicate(context, request): return accept in request.accept - accept_predicate.__text__ = "accept = %s" % accept + accept_predicate.__doc__ = "accept = %s" % accept weights.append(1 << 6) predicates.append(accept_predicate) h.update('accept:%r' % accept) @@ -2566,7 +2566,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, if containment is not None: def containment_predicate(context, request): return find_interface(context, containment) is not None - containment_predicate.__text__ = "containment = %s" % containment + containment_predicate.__doc__ = "containment = %s" % containment weights.append(1 << 7) predicates.append(containment_predicate) h.update('containment:%r' % hash(containment)) @@ -2575,7 +2575,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, def request_type_predicate(context, request): return request_type.providedBy(request) msg = "request type = %s" % request_type - request_type_predicate.__text__ = msg + request_type_predicate.__doc__ = msg weights.append(1 << 8) predicates.append(request_type_predicate) h.update('request_type:%r' % hash(request_type)) @@ -2594,7 +2594,7 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, tvalue = tgenerate(m) m['traverse'] = traversal_path(tvalue) return True - traverse_predicate.__text__ = "traverse = True" + traverse_predicate.__doc__ = "traverse = True" # This isn't actually a predicate, it's just a infodict # modifier that injects ``traverse`` into the matchdict. As a # result, the ``traverse_predicate`` function above always @@ -2604,8 +2604,8 @@ def _make_predicates(xhr=None, request_method=None, path_info=None, if custom: for num, predicate in enumerate(custom): - if not hasattr(predicate, '__text__'): - predicate.__text__ = "custom predicate" + if not hasattr(predicate, '__doc__'): + predicate.__doc__ = "custom predicate" predicates.append(predicate) # using hash() here rather than id() is intentional: we # want to allow custom predicates that are part of @@ -2725,7 +2725,7 @@ def preserve_view_attrs(view, wrapped_view): pass try: wrapped_view.__predicated__ = view.__predicated__ - wrapped_view.__predicates__ = [p.__text__ + wrapped_view.__predicates__ = [p.__doc__ for p in view.__predicates__] except AttributeError: pass diff --git a/pyramid/paster.py b/pyramid/paster.py index a94b4f2d3..368b5de5d 100644 --- a/pyramid/paster.py +++ b/pyramid/paster.py @@ -293,7 +293,7 @@ class PViewsCommand(PCommand): IView, name='', default=None) if view is None: continue - view.__predicates__ = [p.__text__ + view.__predicates__ = [p.__doc__ for p in route.predicates] view.__route_attrs__ = {'matchdict': match, 'matched_route': route, diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index f52d194b6..2bd24ac26 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -5049,7 +5049,7 @@ class DummyStaticURLInfo: class DummyCustomPredicate(object): def __init__(self): - self.__text__ = 'custom predicate' + self.__doc__ = 'custom predicate' def dummy_view(request): return 'OK' |
