##// 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 174 return app(environ, start_response)
175 175
176 176 def __make_app(self):
177 """Make an wsgi application using hgweb, and my generated baseui
178 instance
177 """
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 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 188 name
187 189
188 190 :param action: push or pull action
@@ -206,7 +208,8 b' class SimpleHg(object):'
206 208 return True
207 209
208 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 214 :param environ: environ where PATH_INFO is stored
212 215 """
@@ -224,7 +227,8 b' class SimpleHg(object):'
224 227 return UserModel().get_by_username(username, cache=True)
225 228
226 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 232 This should always return a valid command string
229 233
230 234 :param environ:
@@ -249,16 +253,14 b' class SimpleHg(object):'
249 253 push requests"""
250 254 invalidate_cache('get_repo_cached_%s' % repo_name)
251 255
252 def __load_web_settings(self, hgserve, extras={}):
253 #set the global ui for hgserve instance passed
254 hgserve.repo.ui = self.baseui
256 def __inject_extras(self, baseui, extras={}):
255 257
256 258 hgrc = os.path.join(self.repo_path, '.hg', 'hgrc')
257 259
258 260 #inject some additional parameters that will be available in ui
259 261 #for hooks
260 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 265 repoui = make_ui('file', hgrc, False)
264 266
@@ -266,6 +268,4 b' class SimpleHg(object):'
266 268 #overwrite our ui instance with the section from hgrc file
267 269 for section in ui_sections:
268 270 for k, v in repoui.configitems(section):
269 hgserve.repo.ui.setconfig(section, k, v)
270
271 return hgserve
271 baseui.repo.ui.setconfig(section, k, v)
General Comments 0
You need to be logged in to leave comments. Login now