~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/branchview.py

  • Committer: Robey Pointer
  • Date: 2007-01-02 04:35:59 UTC
  • Revision ID: robey@lag.net-20070102043559-e8knder8lwv46wbz
make the cache folder and branch url (prefix) be optional settings on the
project, so they can be omitted from specific branches under a project and
be assumed.  this is to make it easier to publish many branches under one
project and have them share caches and public urls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
"""
22
22
 
23
23
import logging
 
24
import posixpath
24
25
import threading
25
26
 
26
27
import turbogears
43
44
 
44
45
 
45
46
class BranchView (object):
46
 
    def __init__(self, group_name, name, config):
 
47
    def __init__(self, group_name, name, folder, config, project_config):
47
48
        self._group_name = group_name
48
49
        self._name = name
 
50
        self._folder = folder
49
51
        self._config = config
 
52
        self._project_config = project_config
50
53
        self.log = logging.getLogger('loggerhead.%s' % (name,))
51
54
        
52
55
        # branch history
83
86
 
84
87
    description = property(lambda self: self._config.get('description', ''))
85
88
    
86
 
    branch_url = property(lambda self: self._config.get('url', ''))
 
89
    def _get_branch_url(self):
 
90
        url = self._config.get('url', None)
 
91
        if url is not None:
 
92
            return url
 
93
        # try to assemble one from the project, if an url_prefix was defined.
 
94
        url = self._project_config.get('url_prefix', None)
 
95
        if url is None:
 
96
            return None
 
97
        return posixpath.join(url, self._folder) + '/'
 
98
        
 
99
    branch_url = property(_get_branch_url)
87
100
 
88
101
    @turbogears.expose()
89
102
    def index(self):
103
116
                self._history.detach()
104
117
            self._history = History.from_folder(self._config.get('folder'), self._name)
105
118
            cache_path = self._config.get('cachepath', None)
 
119
            if cache_path is None:
 
120
                # try the project config
 
121
                cache_path = self._project_config.get('cachepath', None)
106
122
            if cache_path is not None:
107
123
                self._history.use_cache(ChangeCache(self._history, cache_path))
108
124
                self._history.use_search_index(TextIndex(self._history, cache_path))