41 """Collects Django urlpatterns info into a simple object. |
41 """Collects Django urlpatterns info into a simple object. |
42 |
42 |
43 The arguments to this constructor correspond directly to the items in |
43 The arguments to this constructor correspond directly to the items in |
44 the urlpatterns tuple, which also correspond to the parameters of |
44 the urlpatterns tuple, which also correspond to the parameters of |
45 django.conf.urls.defaults.url(). |
45 django.conf.urls.defaults.url(). |
46 |
46 |
47 Args: |
47 Args: |
48 regex: a Django URL regex pattern |
48 regex: a Django URL regex pattern, which, for obvious reason, must |
49 view: a Django view, either a string or a callable |
49 be unique |
|
50 view: a Django view, either a string or a callable; if a callable, |
|
51 a unique 'name' string must be supplied |
50 kwargs: optional dict of extra arguments passed to the view |
52 kwargs: optional dict of extra arguments passed to the view |
51 function as keyword arguments, which is copy.deepcopy()'d; |
53 function as keyword arguments, which is copy.deepcopy()'d; |
52 default is None, which supplies an empty dict {} |
54 default is None, which supplies an empty dict {} |
53 name: optional name of the view |
55 name: optional name of the view; used instead of 'view' if supplied; |
|
56 the 'name' or 'view' string, whichever is used, must be unique |
|
57 amongst *all* Url objects supplied to a Page object |
54 prefix: optional view prefix |
58 prefix: optional view prefix |
55 """ |
59 """ |
56 self.regex = regex |
60 self.regex = regex |
57 self.view = view |
61 self.view = view |
58 |
62 |
437 |
441 |
438 def __init__(self, name): |
442 def __init__(self, name): |
439 """Creates a non-linkable Url placeholder. |
443 """Creates a non-linkable Url placeholder. |
440 |
444 |
441 Args: |
445 Args: |
442 name: name of the non-view placeholder |
446 name: name of the non-view placeholder; see Url.__init__() |
443 """ |
447 """ |
444 Url.__init__(self, None, None, name=name) |
448 Url.__init__(self, None, None, name=name) |
445 |
449 |
446 def makeDjangoUrl(self, **extra_kwargs): |
450 def makeDjangoUrl(self, **extra_kwargs): |
447 """Always returns None, since NonUrl is never a Django view. |
451 """Always returns None, since NonUrl is never a Django view. |
452 class NonPage(Page): |
456 class NonPage(Page): |
453 """Placeholder for when a site-map entry is not a displayable page. |
457 """Placeholder for when a site-map entry is not a displayable page. |
454 """ |
458 """ |
455 |
459 |
456 def __init__(self, non_url_name, long_name, **page_kwargs): |
460 def __init__(self, non_url_name, long_name, **page_kwargs): |
457 """ |
461 """Constructs a NonUrl and passes it to base Page class __init__(). |
|
462 |
|
463 Args: |
|
464 non_url_name: unique (it *must* be) string that does not match |
|
465 the 'name' or 'view' of any other Url or NonUrl object; |
|
466 see Url.__init__() for details |
|
467 long_name: see Page.__init__() |
|
468 **page_kwargs: keyword arguments passed directly to the base |
|
469 Page class __init__() |
458 """ |
470 """ |
459 non_url = NonUrl(non_url_name) |
471 non_url = NonUrl(non_url_name) |
460 Page.__init__(self, non_url, long_name, **page_kwargs) |
472 Page.__init__(self, non_url, long_name, **page_kwargs) |