Home | History | Annotate | Download | only in frontend
      1 import os
      2 from django.conf import urls
      3 from django.views import generic
      4 
      5 
      6 def generate_patterns(django_name, gwt_name):
      7     """
      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 
     16     pattern_list = urls.patterns(
     17             django_name,
     18             (r'^(?:|noauth/)rpc/', 'views.handle_rpc'),
     19             (r'^rpc_doc', 'views.rpc_documentation'),
     20         )
     21 
     22     debug_pattern_list = urls.patterns('',
     23             # 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
     32             (r'^$', generic.RedirectView.as_view(
     33                     url='client/autotest.%(name)s/%(name)s.html'
     34                     % dict(name=gwt_name))),
     35         )
     36 
     37     return (pattern_list, debug_pattern_list)
     38