Mercurial > kallithea
comparison rhodecode/lib/middleware/simplehg.py @ 606:f31f1327c1e9
Fixed journal action loggin doubled messages.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 18 Oct 2010 03:39:16 +0200 |
parents | 72bed56219d6 |
children | ff449e9e6e38 |
comparison
equal
deleted
inserted
replaced
605:72bed56219d6 | 606:f31f1327c1e9 |
---|---|
99 'repository.write', | 99 'repository.write', |
100 'repository.admin')\ | 100 'repository.admin')\ |
101 (user, repo_name): | 101 (user, repo_name): |
102 return HTTPForbidden()(environ, start_response) | 102 return HTTPForbidden()(environ, start_response) |
103 | 103 |
104 #log action | 104 #log action |
105 proxy_key = 'HTTP_X_REAL_IP' | 105 if action in ('push', 'pull', 'clone'): |
106 def_key = 'REMOTE_ADDR' | 106 proxy_key = 'HTTP_X_REAL_IP' |
107 ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0')) | 107 def_key = 'REMOTE_ADDR' |
108 self.__log_user_action(user, action, repo_name, ipaddr) | 108 ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0')) |
109 self.__log_user_action(user, action, repo_name, ipaddr) | |
109 | 110 |
110 #=================================================================== | 111 #=================================================================== |
111 # MERCURIAL REQUEST HANDLING | 112 # MERCURIAL REQUEST HANDLING |
112 #=================================================================== | 113 #=================================================================== |
113 environ['PATH_INFO'] = '/'#since we wrap into hgweb, reset the path | 114 environ['PATH_INFO'] = '/'#since we wrap into hgweb, reset the path |
163 def __get_user(self, username): | 164 def __get_user(self, username): |
164 return get_user_cached(username) | 165 return get_user_cached(username) |
165 | 166 |
166 def __get_action(self, environ): | 167 def __get_action(self, environ): |
167 """ | 168 """ |
168 Maps mercurial request commands into a pull or push command. | 169 Maps mercurial request commands into a clone,pull or push command. |
169 This should return generally always something | 170 This should always return a valid command string |
170 :param environ: | 171 :param environ: |
171 """ | 172 """ |
172 mapping = {'changegroup': 'pull', | 173 mapping = {'changegroup': 'pull', |
173 'changegroupsubset': 'pull', | 174 'changegroupsubset': 'pull', |
174 'stream_out': 'pull', | 175 'stream_out': 'pull', |
175 'listkeys': 'pull', | 176 #'listkeys': 'pull', |
176 'unbundle': 'push', | 177 'unbundle': 'push', |
177 'pushkey': 'push', } | 178 'pushkey': 'push', } |
178 for qry in environ['QUERY_STRING'].split('&'): | 179 for qry in environ['QUERY_STRING'].split('&'): |
179 if qry.startswith('cmd'): | 180 if qry.startswith('cmd'): |
180 cmd = qry.split('=')[-1] | 181 cmd = qry.split('=')[-1] |