blob: af2733bc2edeb1274ea3619fc5ced051e0561813 [file] [log] [blame]
showard26b7ec72009-12-21 22:43:57 +00001import os
showardf7130722009-12-23 00:06:16 +00002from django.conf.urls import defaults
showard26b7ec72009-12-21 22:43:57 +00003
4
showardf7130722009-12-23 00:06:16 +00005def generate_patterns(django_name, gwt_name):
showard26b7ec72009-12-21 22:43:57 +00006 """
7 Generates the common URL patterns for the given names
8
9 @param django_name the full name of the Django application
10 (e.g., frontend.afe)
11 @param gwt_name the name of the GWT project (e.g., AfeClient)
12 @return the common standard and the debug pattern lists, as a tuple
13 """
14
showardf7130722009-12-23 00:06:16 +000015 pattern_list = defaults.patterns(
16 django_name,
Scott Zawalski347aaf42012-04-03 16:33:00 -040017 (r'^(?:|noauth/)rpc/', 'views.handle_rpc'),
showardf7130722009-12-23 00:06:16 +000018 (r'^rpc_doc', 'views.rpc_documentation'),
19 )
showard26b7ec72009-12-21 22:43:57 +000020
showardf7130722009-12-23 00:06:16 +000021 debug_pattern_list = defaults.patterns('',
showard26b7ec72009-12-21 22:43:57 +000022 # for GWT hosted mode
23 (r'^(?P<forward_addr>autotest.*)',
24 'autotest_lib.frontend.afe.views.gwt_forward'),
25
26 # for GWT compiled files
27 (r'^client/(?P<path>.*)$', 'django.views.static.serve',
28 {'document_root': os.path.join(os.path.dirname(__file__), '..',
29 'frontend', 'client', 'www')}),
30 # redirect / to compiled client
31 (r'^$', 'django.views.generic.simple.redirect_to',
32 {'url':
33 'client/autotest.%(name)s/%(name)s.html' % dict(name=gwt_name)}),
showardf7130722009-12-23 00:06:16 +000034 )
showard26b7ec72009-12-21 22:43:57 +000035
36 return (pattern_list, debug_pattern_list)