~ubuntu-branches/debian/sid/loggerhead/sid

« back to all changes in this revision

Viewing changes to loggerhead/controllers/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2011-06-02 14:11:55 UTC
  • mto: (13.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20110602141155-1pya25vmwztblmbq
Tags: upstream-1.18.1+bzr447
ImportĀ upstreamĀ versionĀ 1.18.1+bzr447

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 
 
20
import bzrlib.errors
20
21
import time
21
22
 
 
23
from paste.httpexceptions import HTTPNotFound
22
24
from paste.request import path_info_pop, parse_querystring
23
25
 
24
26
from loggerhead import util
92
94
 
93
95
        vals.update(self.get_values(path, kwargs, headers))
94
96
 
95
 
        self.log.info('Getting information for %s: %r secs' % (
 
97
        self.log.info('Getting information for %s: %.3f secs' % (
96
98
            self.__class__.__name__, time.time() - z))
97
99
        if 'Content-Type' not in headers:
98
100
            headers['Content-Type'] = 'text/html'
99
101
        writer = start_response("200 OK", headers.items())
 
102
        if environ.get('REQUEST_METHOD') == 'HEAD':
 
103
            # No content for a HEAD request
 
104
            return []
100
105
        template = load_template(self.template_path)
101
106
        z = time.time()
102
107
        w = BufferingWriter(writer, 8192)
103
108
        template.expand_into(w, **vals)
104
109
        w.flush()
105
110
        self.log.info(
106
 
            'Rendering %s: %r secs, %s bytes' % (
 
111
            'Rendering %s: %.3f secs, %s bytes' % (
107
112
                self.__class__.__name__, time.time() - z, w.bytes))
108
113
        return []
109
114
 
112
117
        if h is None:
113
118
            return None
114
119
        if len(self.args) > 0 and self.args != ['']:
115
 
            return h.fix_revid(self.args[0])
 
120
            try:
 
121
                revid = h.fix_revid(self.args[0])
 
122
            except bzrlib.errors.NoSuchRevision:
 
123
                raise HTTPNotFound;
116
124
        else:
117
 
            return h.last_revid
 
125
            revid = h.last_revid
 
126
        return revid