So, the way to handle these types of links (with the example before):

welcome/default/products/(\d{2})     # shows overall product page for given 
product primary id
welcome/default/products/(\d{2})/description   # shows product description 
for given product primary id
welcome/default/products/(\d{2})/comments   # shows product comments for 
given product primary id
welcome/default/products/(\d{2})/comments/(\d{2})   # shows specific 
comment for a specific product given comment id and product id

Would be to manually check request.args to determine what action to take? I 
imagine it would be kind of messy like this:

def products():
    request_length = len(request.args)

    if request_length == 1:
           # return all info on requested product
    elif request_length == 2:
           if request.args[1] == 'description':
                   # return description of requested product
           elif request.args[1] == 'comments':
                   # return comments of requested product
     elif request_length == 3:
            if request.args[1] == 'comments':
                  # return single comment given its id
     else:
             # redirect to error           

I feel like I'm missing something because this seems a bit 
counter-intuitive and highly messy, especially as the number of urls may 
grow in a large site?



On Tuesday, February 26, 2013 2:13:29 PM UTC-5, Anthony wrote:
>
> In that case, you could do something like:
>
> def places():
>     lastname, firstname = request.args[0:2]
>
> Then for a URL like /myapp/mycontroller/places/John/Doe, "John" would be 
> in request.args[0] and "Doe" would be in request.args[1].
>
> Anthony
>
> On Tuesday, February 26, 2013 11:57:55 AM UTC-5, brac...@gmail.com wrote:
>>
>> Sorry, let me clarify and be more specific again. The framework I 
>> referred to was Django, where their url dispatcher can create named groups 
>> like so:
>>
>> r'^places/(?P<lastname>\w+)/(?P<firstname>\w+)/$', 'misc.views.home'
>>
>>
>> This url would be mapped to a function with the name given in the url:
>>
>>
>> def home(request, lastname, firstname)
>>
>>    # Do something with name and return data to webpage
>>
>>
>>
>> I don't quite understand how web2py's routes.py would handle this.
>>
>>
>>
>>
>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to