Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

# Copyright 2009-2015 Luc Saffre 

# License: BSD (see file COPYING for details) 

 

"""The default URLconf module for Lino applications. 

As an application developer you don't need to worry about this. 

 

This is found by Django because :mod:`lino.projects.std.settings` 

:setting:`ROOT_URLCONF` is set to :mod:`lino.core.urls`. 

 

""" 

 

from django.conf import settings 

from django.conf.urls import url, include 

from django.conf.urls.static import static 

# from lino.core.signals import database_ready 

from lino.core.utils import is_devserver 

 

import lino 

lino.startup() 

# we must explicitly call django.setup() because when running under 

# mod_wsgi this is not done automatically as with runserver (or at 

# least it seems so) 

lino.site_startup() 

 

site = settings.SITE 

urlpatterns = [] 

 

# database_ready.send(site) 

 

if site.site_prefix: 

    prefix = site.site_prefix[1:] 

else: 

    prefix = '' 

rx = '^' + prefix 

 

for p in site.installed_plugins: 

    pat = p.get_patterns() 

    prx = rx 

    if p.url_prefix: 

        prx += p.url_prefix + "/" 

    if prx == '^': 

        urlpatterns += pat 

    else: 

        urlpatterns.append(url(prx, include(pat))) 

 

if site.django_admin_prefix:  # not tested 

    from django.contrib import admin 

    admin.autodiscover() 

    urlpatterns.append(url( 

        rx + site.django_admin_prefix[1:] 

        + "/", include(admin.site.urls))) 

 

#~ logger.info("20130409 is_devserver() returns %s.",is_devserver()) 

if is_devserver(): 

    # from django.contrib.staticfiles.views import serve 

    # opts = {'document_root': settings.MEDIA_ROOT, 

    #         'show_indexes': False} 

    # pat = r'^%s(?P<path>.*)$' % prefix 

    urlpatterns += static( 

        settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 

        # 'django.views.static', (pat, 'serve', opts)) 

 

    # why do i need the following? i thought that this is done 

    # automatically: 

    # urlpatterns += static( 

    #     settings.STATIC_URL, document_root=settings.STATIC_ROOT) 

    # logger.info("20150426 serve static %s -> %s", 

    #             settings.STATIC_URL, settings.STATIC_ROOT) 

 

    # pat = r'^{0}(?P<path>.*)$'.format(settings.STATIC_URL[1:]) 

    # urlpatterns.append(url(pat, serve))