Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.add_route decorator is not working with parameters #54

Open
tonytan4ever opened this issue Feb 28, 2012 · 1 comment
Open

app.add_route decorator is not working with parameters #54

tonytan4ever opened this issue Feb 28, 2012 · 1 comment

Comments

@tonytan4ever
Copy link

I tryied the decorator/function approach to write the views, but it seems not working.

@app.add_route('^/deco/(?P\w+)$', method='GET')
def new_name_handler(application, message, name):
print message
return http_response('Take five, %s!' % (name), 200, 'OK', {})

app.run

gives me this error:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/gevent/greenlet.py", line 390, in run
result = self._run(_self.args, *_self.kwargs)
File "/usr/local/lib/python2.6/dist-packages/brubeck/request_handling.py", line 118, in request_handler
response = handler()
File "/usr/local/lib/python2.6/dist-packages/brubeck/request_handling.py", line 774, in
handler = lambda: kallable(self, message, **kwargs)
TypeError: check_method() got an unexpected keyword argument 'name'
<Greenlet at 0x97ac98c: request_handler(<brubeck.request_handling.Brubeck object at 0x95d9, <brubeck.mongrel2.Request object at 0x98043cc>, <function at 0x97f87d4>)> failed with TypeError

Please show me the correct way of doing it.

@kracekumar
Copy link
Collaborator

Well, can you retest the code since expected Error message is different for me. @tonytan4ever

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/hasgeek/codes/github/brubeck/brubeck/connections.py", line 168, in process_message
    http_content = http_response(result['body'], result['status_code'],
TypeError: string indices must be integers, not str
<Greenlet at 0x1c1a870: <bound method Mongrel2Connection.process_message of <brubeck.connections.Mongrel2Connection object at 0x1c69f90>>(<brubeck.request_handling.Brubeck object at 0x1d0b, '34f9ceee-cd52-4b7f-b197-88bf2f0ec378 57 /name/k/ )> failed with TypeError

official https://github.com/j2labs/brubeck/blob/master/demos/demo_urlargs.py doesn't work as expected.

Output

INFO:root:405 GET /name/krace/ (127.0.0.1)
INFO:root:405 GET /name/krace/1 (127.0.0.1)
INFO:root:405 GET /name/krace (127.0.0.1)

This seems to be bug. Only method allowed here is OPTION. Any pointers ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants