comparison rhodecode/lib/middleware/simplegit.py @ 2026:c6e288dcb4a2 beta

improved logging in git/hg middlewares
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 23 Feb 2012 03:51:39 +0200
parents a04844d9c85b
children 82a88013a3fd 320806ff6be2
comparison
equal deleted inserted replaced
2025:7e979933ffec 2026:c6e288dcb4a2
122 # CHECK ANONYMOUS PERMISSION 122 # CHECK ANONYMOUS PERMISSION
123 #====================================================================== 123 #======================================================================
124 if action in ['pull', 'push']: 124 if action in ['pull', 'push']:
125 anonymous_user = self.__get_user('default') 125 anonymous_user = self.__get_user('default')
126 username = anonymous_user.username 126 username = anonymous_user.username
127 anonymous_perm = self._check_permission(action,anonymous_user, 127 anonymous_perm = self._check_permission(action, anonymous_user,
128 repo_name) 128 repo_name)
129 129
130 if anonymous_perm is not True or anonymous_user.active is False: 130 if anonymous_perm is not True or anonymous_user.active is False:
131 if anonymous_perm is not True: 131 if anonymous_perm is not True:
132 log.debug('Not enough credentials to access this ' 132 log.debug('Not enough credentials to access this '
155 return result.wsgi_application(environ, start_response) 155 return result.wsgi_application(environ, start_response)
156 156
157 #============================================================== 157 #==============================================================
158 # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME 158 # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME
159 #============================================================== 159 #==============================================================
160 log.info('%s action on GIT repo "%s"' % (action, repo_name))
161 if action in ['pull', 'push']: 160 if action in ['pull', 'push']:
162 try: 161 try:
163 user = self.__get_user(username) 162 user = self.__get_user(username)
164 if user is None or not user.active: 163 if user is None or not user.active:
165 return HTTPForbidden()(environ, start_response) 164 return HTTPForbidden()(environ, start_response)
188 187
189 try: 188 try:
190 #invalidate cache on push 189 #invalidate cache on push
191 if action == 'push': 190 if action == 'push':
192 self._invalidate_cache(repo_name) 191 self._invalidate_cache(repo_name)
193 192 log.info('%s action on GIT repo "%s"' % (action, repo_name))
194 app = self.__make_app(repo_name, repo_path) 193 app = self.__make_app(repo_name, repo_path)
195 return app(environ, start_response) 194 return app(environ, start_response)
196 except Exception: 195 except Exception:
197 log.error(traceback.format_exc()) 196 log.error(traceback.format_exc())
198 return HTTPInternalServerError()(environ, start_response) 197 return HTTPInternalServerError()(environ, start_response)