[tipfy] push by rodrigo.moraes - current_handler wasn't being set since last commits. thanks, gorakharg... on 2011-03-23 18:36 GMT

0 views
Skip to first unread message

ti...@googlecode.com

unread,
Mar 23, 2011, 2:37:19 PM3/23/11
to tipfy-...@googlegroups.com
Revision: 9b1efd0b68cc
Author: Rodrigo Moraes <rodrigo...@gmail.com>
Date: Wed Mar 23 11:36:51 2011
Log: current_handler wasn't being set since last commits. thanks,
gorakhargosh.
http://code.google.com/p/tipfy/source/detail?r=9b1efd0b68cc

Modified:
/tests/test_routing.py
/tipfy/routing.py

=======================================
--- /tests/test_routing.py Sun Mar 20 04:48:01 2011
+++ /tests/test_routing.py Wed Mar 23 11:36:51 2011
@@ -4,6 +4,7 @@

from tipfy import Tipfy, RequestHandler, Response
from tipfy.routing import HandlerPrefix, NamePrefix, Router, Rule
+from tipfy.utils import url_for


class TestRouter(BaseTestCase):
@@ -97,6 +98,26 @@
response = client.get('/foo/bar/baz')
self.assertEqual(response.data, 'foo/bar/baz')

+ def test_url_for(self):
+ class DummyHandler(RequestHandler):
+ def get(self, **kwargs):
+ return ''
+
+ rules = [
+ NamePrefix('company-', [
+ Rule('/', name='home', handler=DummyHandler),
+ Rule('/about', name='about', handler=DummyHandler),
+ Rule('/contact', name='contact', handler=DummyHandler),
+ ]),
+ ]
+
+ app = Tipfy(rules)
+
+ with app.get_test_handler('/') as handler:
+ self.assertEqual(url_for('company-home'), '/')
+ self.assertEqual(url_for('company-about'), '/about')
+ self.assertEqual(url_for('company-contact'), '/contact')
+

class TestAlternativeRouting(BaseTestCase):
def test_handler(self):
=======================================
--- /tipfy/routing.py Sun Mar 20 14:40:06 2011
+++ /tipfy/routing.py Wed Mar 23 11:36:51 2011
@@ -94,7 +94,7 @@

rule.handler = handler = self.handlers[handler]

- rv = handler(request.app, request)
+ rv = local.current_handler = handler(request.app, request)
if not isinstance(rv, BaseResponse) and hasattr(rv, '__call__'):
# If it is a callable but not a response, we call it again.
rv = rv()
@@ -128,14 +128,11 @@
:returns:
An absolute or relative URL.
"""
- full = kwargs.pop('_full', False)
method = kwargs.pop('_method', None)
scheme = kwargs.pop('_scheme', None)
netloc = kwargs.pop('_netloc', None)
anchor = kwargs.pop('_anchor', None)
-
- if scheme or netloc:
- full = False
+ full = kwargs.pop('_full', False) and not scheme and not netloc

url = request.url_adapter.build(name, values=kwargs, method=method,
force_external=full)

Reply all
Reply to author
Forward
0 new messages