I could make "asset" function the default for the "showcase" controller
however I am not sure how as I am already using renamed
routes.patterns.example.py in the root of the website (multiple apps) to
rewrite one URL (works nicely):
routes_out = (
('/stock/default/index','/stock'),# <== my addition
# do not reroute admin unless you want to disable it
('/admin/$anything', BASE + '/admin/$anything'),
# do not reroute appadmin unless you want to disable it
('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'),
# do not reroute static files
('/$app/static/$anything', BASE + '/$app/static/$anything'),
# do other stuff
(r'.*http://otherdomain\.com.* /app/ctr(?P<any>.*)', r'\g<any>'),
(r'/app(?P<any>.*)', r'\g<any>'),
# restore the BASE prefix
('/$anything', BASE + '/$anything'),
)
Thanks in advance for any assistance
On Sunday, August 27, 2017 at 12:17:16 PM UTC-4, Anthony wrote:
>
> On Saturday, August 26, 2017 at 4:05:59 PM UTC-4, [email protected]
> <javascript:> wrote:
>>
>> How can I rewrite the URL (to drop asset):
>>
>> https://192.168.1.25:8000/stock/showcase/asset/2017-Some-fridge?id=79&_signature=c2e7899530c858f1b478cb7ea5f03bb30d4f68e1
>> to look like:
>>
>> https://192.168.1.25:8000/stock/showcase/2017-Some-fridge?id=79&_signature=c2e7899530c858f1b478cb7ea5f03bb30d4f68e1
>> the app 'stock' ins't default
>> the controllert 'showcase' isn't default
>> the function 'asset' isn't default
>>
>
> Do you use another function as the default within the "showcase"
> controller? If not, you can define "asset" as the default function just for
> the "showcase" controller using the parameter-based router. Alternatively,
> you can use the default function to handle the above routes by checking for
> a URL arg and returning the appropriate response. For example, if the
> default function is "index":
>
> def index():
> if not request.args:
> [code currently in the "index" function]
> else:
> [code currently in the "asset" function]
>
> Finally, you could use the pattern-based rewrite system, though that can
> start to get complex.
>
> Anthony
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.