blob: b350fcaf2ddb32e8063e2c361c87284ecfeacd46 [file] [log] [blame]
showard26b7ec72009-12-21 22:43:57 +00001import os
Aviv Keshet0a0029f2017-04-17 12:51:39 -07002from django.conf import urls
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
Aviv Keshet0a0029f2017-04-17 12:51:39 -070016 pattern_list = urls.patterns(
showardf7130722009-12-23 00:06:16 +000017 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
Aviv Keshet0a0029f2017-04-17 12:51:39 -070022 debug_pattern_list = urls.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)