blob: ed0d3ce3e96a9dc24c319058b5afc3e82e8d78fe [file] [log] [blame]
showard26b7ec72009-12-21 22:43:57 +00001import os
showardf7130722009-12-23 00:06:16 +00002from django.conf.urls import defaults
Justin Giorgi971b3242016-07-20 15:44:21 -07003from django.views import generic
showard26b7ec72009-12-21 22:43:57 +00004
5
showardf7130722009-12-23 00:06:16 +00006def generate_patterns(django_name, gwt_name):
showard26b7ec72009-12-21 22:43:57 +00007 """
8 Generates the common URL patterns for the given names
9
10 @param django_name the full name of the Django application
11 (e.g., frontend.afe)
12 @param gwt_name the name of the GWT project (e.g., AfeClient)
13 @return the common standard and the debug pattern lists, as a tuple
14 """
15
showardf7130722009-12-23 00:06:16 +000016 pattern_list = defaults.patterns(
17 django_name,
Scott Zawalski347aaf42012-04-03 16:33:00 -040018 (r'^(?:|noauth/)rpc/', 'views.handle_rpc'),
showardf7130722009-12-23 00:06:16 +000019 (r'^rpc_doc', 'views.rpc_documentation'),
20 )
showard26b7ec72009-12-21 22:43:57 +000021
showardf7130722009-12-23 00:06:16 +000022 debug_pattern_list = defaults.patterns('',
showard26b7ec72009-12-21 22:43:57 +000023 # for GWT hosted mode
24 (r'^(?P<forward_addr>autotest.*)',
25 'autotest_lib.frontend.afe.views.gwt_forward'),
26
27 # for GWT compiled files
28 (r'^client/(?P<path>.*)$', 'django.views.static.serve',
29 {'document_root': os.path.join(os.path.dirname(__file__), '..',
30 'frontend', 'client', 'www')}),
31 # redirect / to compiled client
Justin Giorgi971b3242016-07-20 15:44:21 -070032 (r'^$', generic.RedirectView.as_view(
33 url='client/autotest.%(name)s/%(name)s.html'
34 % dict(name=gwt_name))),
showardf7130722009-12-23 00:06:16 +000035 )
showard26b7ec72009-12-21 22:43:57 +000036
37 return (pattern_list, debug_pattern_list)