##// END OF EJS Templates
Added rest controllers for repos and users,...
Added rest controllers for repos and users, templating changes + css fixes

File last commit:

r43:2e1247e6 default
r47:f6ac7918 default
Show More
hg.py
41 lines | 1.6 KiB | text/x-python | PythonLexer
Marcin Kuzminski
initial commit.
r0 #!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
changed for pylons 0.1 / 1.0...
r43 from pylons_app.lib.base import BaseController
Marcin Kuzminski
Added app basic auth....
r41 from pylons import tmpl_context as c, app_globals as g, session, request, config
Marcin Kuzminski
Removed default contact name...
r22 from pylons_app.lib import helpers as h
Marcin Kuzminski
initial commit.
r0 from mako.template import Template
Bugfix when client is using old mercurial version and not setting http accept
r37 from pylons.controllers.util import abort
Marcin Kuzminski
Added app basic auth....
r41
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 log = logging.getLogger(__name__)
Marcin Kuzminski
initial commit.
r0
class HgController(BaseController):
Marcin Kuzminski
Wrapped into mako templates,...
r21
def __before__(self):
Marcin Kuzminski
Added app basic auth....
r41 c.repos_prefix = config['repos_name']
Marcin Kuzminski
Wrapped into mako templates,...
r21
Marcin Kuzminski
Changed to webapp, removed get from routes,
r8 def view(self, *args, **kwargs):
Marcin Kuzminski
Wrapped into mako templates,...
r21 response = g.hgapp(request.environ, self.start_response)
Bugfix when client is using old mercurial version and not setting http accept
r37
http_accept = request.environ.get('HTTP_ACCEPT', False)
if not http_accept:
return abort(status_code=400, detail='no http accept in header')
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 #for mercurial protocols and raw files we can't wrap into mako
Bugfix when client is using old mercurial version and not setting http accept
r37 if http_accept.find("mercurial") != -1 or \
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 request.environ['PATH_INFO'].find('raw-file') != -1:
Marcin Kuzminski
Wrapped into mako templates,...
r21 return response
Marcin Kuzminski
dirty fix for multiple file encodings,
r32 try:
tmpl = u''.join(response)
template = Template(tmpl, lookup=request.environ['pylons.pylons']\
Marcin Kuzminski
Added app basic auth....
r41 .config['pylons.app_globals'].mako_lookup)
Marcin Kuzminski
dirty fix for multiple file encodings,
r32
except (RuntimeError, UnicodeDecodeError):
log.info('disabling unicode due to encoding error')
response = g.hgapp(request.environ, self.start_response)
tmpl = ''.join(response)
template = Template(tmpl, lookup=request.environ['pylons.pylons']\
Marcin Kuzminski
Added app basic auth....
r41 .config['pylons.app_globals'].mako_lookup, disable_unicode=True)
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31
Marcin Kuzminski
Wrapped into mako templates,...
r21
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 return template.render(g=g, c=c, session=session, h=h)