/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/apps/config.py

  • Committer: Michael Hudson
  • Date: 2008-06-18 06:55:47 UTC
  • mto: This revision was merged to the branch mainline in revision 164.
  • Revision ID: michael.hudson@canonical.com-20080618065547-kclcku5kb5wjlqqr
hackish support for noticing when a branch has changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
from loggerhead.apps.branch import BranchWSGIApp
15
15
from loggerhead.apps import static_app
 
16
from loggerhead.changecache import FileChangeCache
16
17
from loggerhead.history import History
17
18
from loggerhead.templatefunctions import templatefunctions
18
19
from loggerhead.zptsupport import load_template
83
84
        description = view.get_history().get_config().get_user_option('description')
84
85
        return description
85
86
 
 
87
    def _make_history(self, view_name, view_config, folder):
 
88
        h = History.from_folder(folder, view_name)
 
89
        cache_path = view_config.get('cachepath', None)
 
90
        if cache_path is None:
 
91
            # try the project config
 
92
            cache_path = self._config.get('cachepath', None)
 
93
        if cache_path is not None:
 
94
            h.use_file_cache(FileChangeCache(h, cache_path))
 
95
 
 
96
 
86
97
    def _add_view(self, view_name, view_config, folder):
87
 
        h = History.from_folder(folder)
 
98
        h = self._make_history(view_name, view_config, folder)
88
99
        friendly_name = view_config.get('branch_name', None)
89
100
        if friendly_name is None:
90
101
            friendly_name = h.get_config().get_nickname()
96
107
        if branch_url is not None:
97
108
            view.branch_url = branch_url
98
109
        view.description = self._get_description(view)
 
110
        view._src_folder = folder
 
111
        view._view_config = view_config
99
112
        self.views.append(view)
100
113
        self.views_by_name[view_name] = view
101
114
 
107
120
            view = self.views_by_name.get(segment)
108
121
            if view is None:
109
122
                raise httpexceptions.HTTPNotFound()
 
123
            if view.history.out_of_date():
 
124
                view.history = self._make_history(view.name, view._view_config, view._src_folder)
110
125
            return view.app(environ, start_response)
111
126
 
112
127