~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/apps/config.py

  • Committer: Martin Albisetti
  • Date: 2008-07-26 17:41:49 UTC
  • mfrom: (183.2.1 copyright)
  • Revision ID: argentina@gmail.com-20080726174149-o64p6v3p3301km91
 * Clarify License and add copyright to all file headers (John Arbash Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
import bzrlib.lru_cache
12
12
 
13
 
from bzrlib.util.configobj.configobj import ConfigObj
 
13
from configobj import ConfigObj
14
14
 
15
15
from paste.request import path_info_pop
16
16
from paste import httpexceptions
17
17
from paste.wsgiwrappers import WSGIResponse
18
18
 
19
19
from loggerhead.apps.branch import BranchWSGIApp
20
 
from loggerhead.apps import favicon_app, static_app, robots_app
 
20
from loggerhead.apps import favicon_app, static_app
21
21
from loggerhead.templatefunctions import templatefunctions
22
22
from loggerhead.zptsupport import load_template
23
23
from loggerhead import util
26
26
 
27
27
from loggerhead.history import is_branch
28
28
 
29
 
 
30
29
class Project(object):
31
30
    """A project contains the branches.
32
31
 
74
73
        log.debug('Rescanning auto-folder for project %s ...', self.name)
75
74
        for folder in auto_list:
76
75
            view_name = os.path.basename(folder)
77
 
            log.debug('Auto-configuring (project %s) branch %s...',
78
 
                      self.name,
79
 
                      view_name)
 
76
            log.debug('Auto-configuring (project %s) branch %s...', self.name, view_name)
80
77
            self._add_view(view_name, ConfigObj(), folder)
81
78
        self._auto_list = auto_list
82
79
 
93
90
        description = view_config.get('description', None)
94
91
        if description is not None:
95
92
            return description
96
 
        description = history._branch.get_config().get_user_option(
97
 
                          'description')
 
93
        description = history._branch.get_config().get_user_option('description')
98
94
        return description
99
95
 
100
96
    def _add_view(self, view_name, view_config, folder):
111
107
            self.view_data_by_name[view_name] = {
112
108
                'branch_path': folder,
113
109
                'args': (view_name, view_config, self.graph_cache),
114
 
                'description': self._get_description(view,
115
 
                                                     view_config,
116
 
                                                     history),
 
110
                'description': self._get_description(view, view_config, history),
117
111
                '_src_folder': folder,
118
112
                '_view_config': view_config,
119
113
                'friendly_name': friendly_name,
164
158
        self.projects_by_name = {}
165
159
        graph_cache = bzrlib.lru_cache.LRUCache()
166
160
        for project_name in self.config.sections:
167
 
            project = Project(project_name, self.config[project_name],
168
 
                              self.config, graph_cache)
 
161
            project = Project(
 
162
                project_name, self.config[project_name], self.config, graph_cache)
169
163
            self.projects.append(project)
170
164
            self.projects_by_name[project_name] = project
171
165
 
175
169
        # branches again.
176
170
        for p in self.projects:
177
171
            p._recheck_auto_folders()
178
 
 
179
172
        class branch(object):
180
 
 
181
173
            @staticmethod
182
174
            def static_url(path):
183
175
                return self._static_url_base + path
216
208
            response = WSGIResponse()
217
209
            self.browse(response)
218
210
            return response(environ, start_response)
219
 
        elif segment == 'robots.txt':
220
 
            return robots_app(environ, start_response)
221
211
        elif segment == 'static':
222
212
            return static_app(environ, start_response)
223
213
        elif segment == 'favicon.ico':