Re: py4web routing and parameter passing

314 views
Skip to first unread message
Message has been deleted

Jim S

unread,
Jan 20, 2020, 12:30:29 AM1/20/20
to web2py-users
My bad - I was truly generating an invalid URL.  My code is now working just like the example in the documentation.

-Jim

On Sunday, January 19, 2020 at 10:17:17 PM UTC-6, Jim S wrote:
Given this excerpt from the py4web documentation:

The request object

From py4web you can import request

from py4web import request

@action('paint')
def paint():
   
if 'color' in request.query
       
return 'Painting in %s' % request.query.get('color')
   
return 'You did not specify a color'

This action can be accessed at:

http
://localhost:8000/myapp/paint?color=red

Notice that the request object is the a Bottle request object


My controller signature looks like this:

@action('administration/links', method=['GET', 'POST'])
@action.uses('list.html', session, db, auth.user)
def links():
    current_page_number
= request.query.get('page') if 'page' in request.query else 1

But, when I try to access:


I get a 404 error. - WARNING:tornado.access:404 GET /py4web_test/link?page=2 (127.0.0.1) 1.79ms

I'm not sure what I'm doing wrong.  Is there a way to tell it that you have an optional parameter that may or may not be passed in?

-Jim




Reply all
Reply to author
Forward
0 new messages