~ubuntu-branches/debian/jessie/loggerhead/jessie

« back to all changes in this revision

Viewing changes to loggerhead/controllers/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2008-12-09 01:04:39 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081209010439-67a169sw58q1nru3
Tags: 1.10-1
* New upstream release.
* Stop writing home directory to pid file. (Closes: #507002)
* Use objlib from bzr. (Closes: #506999)
* Fix dependency on python-paste.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
    template_path = None
60
60
 
61
 
    def __init__(self, branch, history):
 
61
    def __init__(self, branch, history_callable):
62
62
        self._branch = branch
63
 
        self._history = history
 
63
        self._history_callable = history_callable
 
64
        self.__history = None
64
65
        self.log = branch.log
65
66
 
 
67
    @property
 
68
    def _history(self):
 
69
        if self.__history is not None:
 
70
            return self.__history
 
71
        self.__history = self._history_callable()
 
72
        return self.__history
 
73
 
66
74
    def __call__(self, environ, start_response):
67
75
        z = time.time()
68
 
        h = self._history
69
76
        kwargs = dict(parse_querystring(environ))
70
77
        util.set_context(kwargs)
71
78
        args = []
75
82
                break
76
83
            args.append(arg)
77
84
 
78
 
        revid = None
79
 
        if h is not None:
80
 
            if len(args) > 0:
81
 
                revid = h.fix_revid(args[0])
82
 
            else:
83
 
                revid = h.last_revid
84
 
 
85
85
        path = None
86
86
        if len(args) > 1:
87
87
            path = '/'.join(args[1:])
 
88
        self.args = args
88
89
 
89
90
        vals = {
90
91
            'static_url': self._branch.static_url,
91
92
            'branch': self._branch,
92
93
            'util': util,
93
 
            'history': h,
94
94
            'url': self._branch.context_url,
95
95
        }
96
96
        vals.update(templatefunctions)
97
97
        headers = {}
98
 
        vals.update(self.get_values(h, revid, path, kwargs, headers))
 
98
 
 
99
        vals.update(self.get_values(path, kwargs, headers))
99
100
 
100
101
        self.log.info('Getting information for %s: %r secs' % (
101
102
            self.__class__.__name__, time.time() - z))
115
116
                w.bytes_saved,
116
117
                100.0*w.bytes_saved/w.bytes))
117
118
        return []
 
119
 
 
120
    def get_revid(self):
 
121
        h = self._history
 
122
        if h is None:
 
123
            return None
 
124
        if len(self.args) > 0:
 
125
            return h.fix_revid(self.args[0])
 
126
        else:
 
127
            return h.last_revid