public
Created

Exemplo usado na vídeo aula de rotas

  • Download Gist
routes.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'clientes' # ordinarily set in base routes.py
default_controller = 'clientes' # ordinarily set in app-specific routes.py
default_function = 'novo' # ordinarily set in app-specific routes.py
 
# Routes In
 
routes_in = (
# Lista de Clientes
(r'/lista',r'/clientes/clientes/lista'),
 
# Detalhes do Cliente
(r'/cliente/$id_cliente',r'/clientes/clientes/detalhes/$id_cliente'),
(r'/cliente/$id_cliente/$outra_arg',r'/clientes/clientes/detalhes/$id_cliente/$outra_arg'),
(r'/cliente/$id_cliente/$outra_arg/$arg3',r'/clientes/clientes/detalhes/$id_cliente/$outra_arg/$arg3'),
 
# Novo Cliente
(r'/cliente/novo',r'/clientes/clientes/novo'),
)
 
# Routes Out
 
routes_out = (
# Lista de Clientes
(r'/clientes/clientes/lista',r'/lista'),
 
#Detalhes do Cliente
(r'/clientes/clientes/detalhes/$id_cliente',r'/cliente/$id_cliente'),
(r'/clientes/clientes/detalhes/$id_cliente/$outra_arg',r'/cliente/$id_cliente/$outra_arg'),
(r'/clientes/clientes/detalhes/$id_cliente/$outra_arg/$arg3',r'/cliente/$id_cliente/$outra_arg/$arg3'),
 
# Novo Cliente
(r'/clientes/clientes/novo',r'/cliente/novo'),
)
 
# Error-handling redirects all HTTP errors (status codes >= 400) to a specified
# path. If you wish to use error-handling redirects, uncomment the tuple
# below. You can customize responses by adding a tuple entry with the first
# value in 'appName/HTTPstatusCode' format. ( Only HTTP codes >= 400 are
# routed. ) and the value as a path to redirect the user to. You may also use
# '*' as a wildcard.
#
# The error handling page is also passed the error code and ticket as
# variables. Traceback information will be stored in the ticket.
#
# routes_onerror = [
# (r'init/400', r'/init/default/login')
# ,(r'init/*', r'/init/static/fail.html')
# ,(r'*/404', r'/init/static/cantfind.html')
# ,(r'*/*', r'/init/error/index')
# ]
 
# specify action in charge of error handling
#
# error_handler = dict(application='error',
# controller='default',
# function='index')
 
# In the event that the error-handling page itself returns an error, web2py will
# fall back to its old static responses. You can customize them here.
# ErrorMessageTicket takes a string format dictionary containing (only) the
# "ticket" key.
 
# error_message = '<html><body><h1>Invalid request</h1></body></html>'
# error_message_ticket = '<html><body><h1>Internal error</h1>Ticket issued: <a href="/admin/default/ticket/%(ticket)s" target="_blank">%(ticket)s</a></body></html>'
 
# specify a list of apps that bypass args-checking and use request.raw_args
#
#routes_apps_raw=['myapp']
#routes_apps_raw=['myapp', 'myotherapp']

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.