Changeset - 24dbf4bc57aa
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 15 years ago 2010-05-21 20:58:18
marcin@python-works.com
simplehg update
1 file changed with 14 insertions and 13 deletions:
0 comments (0 inline, 0 general)
pylons_app/lib/simplehg.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
#
 
# Copyright (c) 2010 marcink.  All rights reserved.
 
#
 
"""
 
Created on 2010-04-28
 

	
 
@author: marcink
 
SimpleHG middleware for handling mercurial protocol request (push/clone etc.)
 
It's implemented with basic auth function
 
"""
 

	
 
from mercurial.hgweb import hgweb
 
from mercurial.hgweb.request import wsgiapplication
 
from paste.auth.basic import AuthBasicAuthenticator
 
from paste.httpheaders import REMOTE_USER, AUTH_TYPE
 
from pylons.controllers.util import abort
 
from pylons_app.lib.utils import is_mercurial
 
from pylons_app.lib.auth import authfunc
 
from pylons_app.lib.utils import make_ui, invalidate_cache
 
from webob.exc import HTTPNotFound
 
import os
 

	
 
class SimpleHg(object):
 
@@ -68,18 +81,6 @@ class SimpleHg(object):
 
            #set the repository based config
 
            hgserve.repo.ui = repoui
 
            
 
        return hgserve
 

	
 

	
 
                                
 
def is_mercurial(environ):
 
    """
 
    Returns True if request's target is mercurial server - header
 
    ``HTTP_ACCEPT`` of such request would start with ``application/mercurial``.
 
    """
 
    http_accept = environ.get('HTTP_ACCEPT')
 
    if http_accept and http_accept.startswith('application/mercurial'):
 
        return True
 
    return False
 

	
 

	
0 comments (0 inline, 0 general)