how to obtain clean URL string

25 views
Skip to first unread message

Alex Glaros

unread,
Aug 30, 2016, 6:46:21 PM8/30/16
to web...@googlegroups.com
.load file sends parent URL to a controller in long form, including alll parts of the URL:   controller_to_return_to=request.env.http_web2py_component_location

controller then does a redirect to parent

how to get the abreviated form of the URL? The original var controller_to_return_to looks like this when sent through the "Sure you want to delete?" URL: 

I had to resort to this:

    new_controller_index = max(loc for loc, val in enumerate(controller_to_return_to) if val == '/') # First find the last slash in the string
    extra_controller = controller_to_return_to[(new_controller_index+1):]  # strip off extra URL characters. Looks hacky.
    form = FORM.confirm('Sure you want to delete this comment?',{'Back':URL(extra_controller)})

better way?

thanks,

Alex Glaros

Dave S

unread,
Aug 30, 2016, 7:23:55 PM8/30/16
to web2py-users


Maybe Python's urlparse library?

/dps
 
Reply all
Reply to author
Forward
0 new messages