Mercurial > public > src > rhodecode
comparison pylons_app/lib/middleware/simplehg.py @ 364:1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 14 Jul 2010 02:28:32 +0200 |
parents | 71f25781079d |
children | 6484963056cd |
comparison
equal
deleted
inserted
replaced
362:71f25781079d | 364:1ef52a70f3b7 |
---|---|
48 | 48 |
49 def __init__(self, application, config): | 49 def __init__(self, application, config): |
50 self.application = application | 50 self.application = application |
51 self.config = config | 51 self.config = config |
52 #authenticate this mercurial request using | 52 #authenticate this mercurial request using |
53 realm = '%s %s' % (self.config['hg_app_name'], 'mercurial repository') | 53 realm = self.config['hg_app_auth_realm'] |
54 self.authenticate = AuthBasicAuthenticator(realm, authfunc) | 54 self.authenticate = AuthBasicAuthenticator(realm, authfunc) |
55 | 55 |
56 def __call__(self, environ, start_response): | 56 def __call__(self, environ, start_response): |
57 if not is_mercurial(environ): | 57 if not is_mercurial(environ): |
58 return self.application(environ, start_response) | 58 return self.application(environ, start_response) |
109 | 109 |
110 #=================================================================== | 110 #=================================================================== |
111 # MERCURIAL REQUEST HANDLING | 111 # MERCURIAL REQUEST HANDLING |
112 #=================================================================== | 112 #=================================================================== |
113 environ['PATH_INFO'] = '/'#since we wrap into hgweb, reset the path | 113 environ['PATH_INFO'] = '/'#since we wrap into hgweb, reset the path |
114 self.baseui = make_ui(self.config['hg_app_repo_conf']) | 114 self.baseui = make_ui('db') |
115 self.basepath = self.config['base_path'] | 115 self.basepath = self.config['base_path'] |
116 self.repo_path = os.path.join(self.basepath, repo_name) | 116 self.repo_path = os.path.join(self.basepath, repo_name) |
117 | 117 |
118 #quick check if that dir exists... | 118 #quick check if that dir exists... |
119 if check_repo_fast(repo_name, self.basepath): | 119 if check_repo_fast(repo_name, self.basepath): |
120 return HTTPNotFound()(environ, start_response) | 120 return HTTPNotFound()(environ, start_response) |
121 | |
122 try: | 121 try: |
123 app = wsgiapplication(self.__make_app) | 122 app = wsgiapplication(self.__make_app) |
124 except RepoError as e: | 123 except RepoError as e: |
125 if str(e).find('not found') != -1: | 124 if str(e).find('not found') != -1: |
126 return HTTPNotFound()(environ, start_response) | 125 return HTTPNotFound()(environ, start_response) |
153 yield msg + '\n' | 152 yield msg + '\n' |
154 org_response = app(environ, start_response) | 153 org_response = app(environ, start_response) |
155 return chain(org_response, custom_messages(messages)) | 154 return chain(org_response, custom_messages(messages)) |
156 | 155 |
157 def __make_app(self): | 156 def __make_app(self): |
158 hgserve = hgweb(self.repo_path) | 157 hgserve = hgweb(str(self.repo_path), baseui=self.baseui) |
159 return self.__load_web_settings(hgserve) | 158 return self.__load_web_settings(hgserve) |
160 | 159 |
161 def __get_environ_user(self, environ): | 160 def __get_environ_user(self, environ): |
162 return environ.get('REMOTE_USER') | 161 return environ.get('REMOTE_USER') |
163 | 162 |
212 invalidate_cache('cached_repo_list') | 211 invalidate_cache('cached_repo_list') |
213 invalidate_cache('full_changelog', repo_name) | 212 invalidate_cache('full_changelog', repo_name) |
214 | 213 |
215 | 214 |
216 def __load_web_settings(self, hgserve): | 215 def __load_web_settings(self, hgserve): |
217 repoui = make_ui(os.path.join(self.repo_path, '.hg', 'hgrc'), False) | |
218 #set the global ui for hgserve | 216 #set the global ui for hgserve |
219 hgserve.repo.ui = self.baseui | 217 hgserve.repo.ui = self.baseui |
218 | |
219 hgrc = os.path.join(self.repo_path, '.hg', 'hgrc') | |
220 repoui = make_ui('file', hgrc, False) | |
220 | 221 |
221 if repoui: | 222 if repoui: |
222 #set the repository based config | 223 #set the repository based config |
223 hgserve.repo.ui = repoui | 224 hgserve.repo.ui = repoui |
224 | 225 |