showard | 26b7ec7 | 2009-12-21 22:43:57 +0000 | [diff] [blame] | 1 | import os |
showard | f713072 | 2009-12-23 00:06:16 +0000 | [diff] [blame] | 2 | from django.conf.urls import defaults |
showard | 26b7ec7 | 2009-12-21 22:43:57 +0000 | [diff] [blame] | 3 | |
| 4 | |
showard | f713072 | 2009-12-23 00:06:16 +0000 | [diff] [blame] | 5 | def generate_patterns(django_name, gwt_name): |
showard | 26b7ec7 | 2009-12-21 22:43:57 +0000 | [diff] [blame] | 6 | """ |
| 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 | |
showard | f713072 | 2009-12-23 00:06:16 +0000 | [diff] [blame] | 15 | pattern_list = defaults.patterns( |
| 16 | django_name, |
Scott Zawalski | 347aaf4 | 2012-04-03 16:33:00 -0400 | [diff] [blame] | 17 | (r'^(?:|noauth/)rpc/', 'views.handle_rpc'), |
showard | f713072 | 2009-12-23 00:06:16 +0000 | [diff] [blame] | 18 | (r'^rpc_doc', 'views.rpc_documentation'), |
| 19 | ) |
showard | 26b7ec7 | 2009-12-21 22:43:57 +0000 | [diff] [blame] | 20 | |
showard | f713072 | 2009-12-23 00:06:16 +0000 | [diff] [blame] | 21 | debug_pattern_list = defaults.patterns('', |
showard | 26b7ec7 | 2009-12-21 22:43:57 +0000 | [diff] [blame] | 22 | # 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)}), |
showard | f713072 | 2009-12-23 00:06:16 +0000 | [diff] [blame] | 34 | ) |
showard | 26b7ec7 | 2009-12-21 22:43:57 +0000 | [diff] [blame] | 35 | |
| 36 | return (pattern_list, debug_pattern_list) |