Hello,
 Please can someone help with a routing problem? I'm using pattern-based 
routing (config below), mainly to map for example: 

"/servers/server-123.json" to "/ids/servers/view.json?NAME=server-123"

using routes.py entry:

   ("/servers/$hostname.json","/ids/servers/view.json?NAME=$hostname")


It works fine with "NAME=server" but if I have "NAME=server-123" 
(/servers/servers-123.json) , I get an "invalid request" error. It looks 
this is due to a restriction on having hyphens in application names and/or 
issues parsing with hyphens in the name.

Please can anyone suggestion an alternative configuration, to allow hyphens 
in the URL parameters?

Thank you!


*web2py/routes.py*

# -*- 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, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'ids'    # ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'      # ordinarily set in app-specific routes.py

# routes_app is a tuple of tuples.  The first item in each is a regexp that 
will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base 
routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:


routes_app = ((r'/(?P<app>welcome|admin|ids)\b.*', r'\g<app>'),
              (r'(.*)', r'ids'),
              (r'/?(.*)', r'ids'))



*web2py/applications/ids/routes.py*
# -*- 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 = 'ids'    # ordinarily set in base routes.py
# default_controller = 'default'  # ordinarily set in app-specific routes.py
# default_function = 'index'      # ordinarily set in app-specific routes.py
# routes_app is a tuple of tuples.  The first item in each is a regexp that 
will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base 
routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:
#
#
# routes_app = ((r'/(?P<app>admin|gio_sds)', r'\g<app>'),
#               (r'(.*)', r'gio_sds'),
#               (r'/?(.*)', r'gio_sds'))


routes_in = (
  ('/admin/$anything', '/admin/$anything'),
   # ('/default/$anything', '/default/$anything'),
 ('/default/user/login.json', '/ids/default/user/login'),
   ('/default/user/$anything', '/default/user/$anything'),
   ('/default/$anything', '/default/$anything'),
  ('/static/$anything', '/ids/static/$anything'),
  ('/appadmin/$anything', '/ids/appadmin/$anything'),
  ('/favicon.ico', '/ids/static/favicon.ico'),
  ('/robots.txt', '/ids/static/robots.txt'),


   ("/servers/index.html","/ids/servers/index.html"),
  ("/servers/index.json","/ids/servers/index.json"),
   ("/servers/$hostname","/ids/servers/view?NAME=$hostname"),
*   ("/servers/$hostname.json","/ids/servers/view.json?NAME=$hostname"),*
   ("/servers/$hostname.html","/ids/servers/view.html?NAME=$hostname"),
   ('/servers/$anything', '/servers/$anything'),

)

routes_out = [(x, y) for (y, x) in routes_in]

-- 
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.

Reply via email to