26 |
26 |
27 |
27 |
28 def addPages(pages): |
28 def addPages(pages): |
29 global SITEMAP |
29 global SITEMAP |
30 SITEMAP += pages |
30 SITEMAP += pages |
|
31 |
|
32 |
|
33 def getDjangoURLPatterns(params): |
|
34 """Retrieves a list of sidebar entries for this view from self._params. |
|
35 |
|
36 Params usage: |
|
37 The params dictionary is passed to the getKeyFieldsPatterns |
|
38 method, see it's docstring on how it is used. |
|
39 django_patterns: The django_patterns value is returned directly |
|
40 if it is non-False. |
|
41 django_patterns_defaults: The dajngo_patterns_defaults value is |
|
42 used to construct the url patterns. It is expected to be a |
|
43 list of tuples. The tuples should contain an url, a module |
|
44 name, and the name of the url. The name is used as the |
|
45 page_name passed as keyword argument, but also as the name |
|
46 by which the url is known to Django internally. |
|
47 url_name: The url_name argument is passed as argument to each |
|
48 url, together with the link_id pattern, the link_id core |
|
49 pattern, and the key fields for this View. |
|
50 |
|
51 Args: |
|
52 params: a dict with params for this View |
|
53 """ |
|
54 |
|
55 # Return the found result |
|
56 if params['django_patterns']: |
|
57 return params['django_patterns'] |
|
58 |
|
59 # Construct defaults manualy |
|
60 default_patterns = params['django_patterns_defaults'] |
|
61 key_fields_pattern = params['key_fields_pattern'] |
|
62 |
|
63 patterns = [] |
|
64 |
|
65 for url, module, name in default_patterns: |
|
66 name = name % params |
|
67 module = module % params['module_name'] |
|
68 |
|
69 url = url % { |
|
70 'url_name': params['url_name'], |
|
71 'lnp': params['link_id_arg_pattern'], |
|
72 'ulnp': params['link_id_pattern_core'], |
|
73 'key_fields': key_fields_pattern, |
|
74 } |
|
75 |
|
76 kwargs = {'page_name': name} |
|
77 |
|
78 item = (url, module, kwargs, name) |
|
79 patterns.append(item) |
|
80 |
|
81 return patterns |