##// END OF EJS Templates
small rewrite for injecting rhodecode_extras into ui. instead of injecting to hgweb instance, inject to ui and pass to hgweb. It's simpler and more readable.
marcink -
r1276:88e75052 beta
parent child Browse files
Show More
@@ -174,15 +174,17 b' class SimpleHg(object):'
174 return app(environ, start_response)
174 return app(environ, start_response)
175
175
176 def __make_app(self):
176 def __make_app(self):
177 """Make an wsgi application using hgweb, and my generated baseui
177 """
178 instance
178 Make an wsgi application using hgweb, and inject generated baseui
179 instance, additionally inject some extras into ui object
179 """
180 """
181 self.__inject_extras(self.baseui, self.extras)
182 return hgweb(str(self.repo_path), baseui=self.baseui)
180
183
181 hgserve = hgweb(str(self.repo_path), baseui=self.baseui)
182 return self.__load_web_settings(hgserve, self.extras)
183
184
184 def __check_permission(self, action, user, repo_name):
185 def __check_permission(self, action, user, repo_name):
185 """Checks permissions using action (push/pull) user and repository
186 """
187 Checks permissions using action (push/pull) user and repository
186 name
188 name
187
189
188 :param action: push or pull action
190 :param action: push or pull action
@@ -206,7 +208,8 b' class SimpleHg(object):'
206 return True
208 return True
207
209
208 def __get_repository(self, environ):
210 def __get_repository(self, environ):
209 """Get's repository name out of PATH_INFO header
211 """
212 Get's repository name out of PATH_INFO header
210
213
211 :param environ: environ where PATH_INFO is stored
214 :param environ: environ where PATH_INFO is stored
212 """
215 """
@@ -224,7 +227,8 b' class SimpleHg(object):'
224 return UserModel().get_by_username(username, cache=True)
227 return UserModel().get_by_username(username, cache=True)
225
228
226 def __get_action(self, environ):
229 def __get_action(self, environ):
227 """Maps mercurial request commands into a clone,pull or push command.
230 """
231 Maps mercurial request commands into a clone,pull or push command.
228 This should always return a valid command string
232 This should always return a valid command string
229
233
230 :param environ:
234 :param environ:
@@ -249,16 +253,14 b' class SimpleHg(object):'
249 push requests"""
253 push requests"""
250 invalidate_cache('get_repo_cached_%s' % repo_name)
254 invalidate_cache('get_repo_cached_%s' % repo_name)
251
255
252 def __load_web_settings(self, hgserve, extras={}):
256 def __inject_extras(self, baseui, extras={}):
253 #set the global ui for hgserve instance passed
254 hgserve.repo.ui = self.baseui
255
257
256 hgrc = os.path.join(self.repo_path, '.hg', 'hgrc')
258 hgrc = os.path.join(self.repo_path, '.hg', 'hgrc')
257
259
258 #inject some additional parameters that will be available in ui
260 #inject some additional parameters that will be available in ui
259 #for hooks
261 #for hooks
260 for k, v in extras.items():
262 for k, v in extras.items():
261 hgserve.repo.ui.setconfig('rhodecode_extras', k, v)
263 baseui.setconfig('rhodecode_extras', k, v)
262
264
263 repoui = make_ui('file', hgrc, False)
265 repoui = make_ui('file', hgrc, False)
264
266
@@ -266,6 +268,4 b' class SimpleHg(object):'
266 #overwrite our ui instance with the section from hgrc file
268 #overwrite our ui instance with the section from hgrc file
267 for section in ui_sections:
269 for section in ui_sections:
268 for k, v in repoui.configitems(section):
270 for k, v in repoui.configitems(section):
269 hgserve.repo.ui.setconfig(section, k, v)
271 baseui.repo.ui.setconfig(section, k, v)
270
271 return hgserve
General Comments 0
You need to be logged in to leave comments. Login now