Changeset - a9a6c74ad2a6
[Not reviewed]
default
0 2 0
Marcin Kuzminski - 15 years ago 2010-07-01 20:10:22
marcin@python-works.com
added ip loggin into mercurial middleware
2 files changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
pylons_app/lib/middleware/simplehg.py
Show inline comments
 
@@ -98,7 +98,10 @@ class SimpleHg(object):
 
                        return HTTPForbidden()(environ, start_response)
 
                
 
                #log action    
 
                self.__log_user_action(user, action, repo_name)            
 
                proxy_key = 'HTTP_X_REAL_IP'
 
                def_key = 'REMOTE_ADDR'
 
                ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0'))
 
                self.__log_user_action(user, action, repo_name, ipaddr)            
 
            
 
            #===================================================================
 
            # MERCURIAL REQUEST HANDLING
 
@@ -162,7 +165,7 @@ class SimpleHg(object):
 
                if mapping.has_key(cmd):
 
                    return mapping[cmd]
 
    
 
    def __log_user_action(self, user, action, repo):
 
    def __log_user_action(self, user, action, repo, ipaddr):
 
        sa = meta.Session
 
        try:
 
            user_log = UserLog()
 
@@ -170,6 +173,7 @@ class SimpleHg(object):
 
            user_log.action = action
 
            user_log.repository = repo.replace('/', '')
 
            user_log.action_date = datetime.now()
 
            user_log.user_ip = ipaddr
 
            sa.add(user_log)
 
            sa.commit()
 
            log.info('Adding user %s, action %s on %s',
pylons_app/templates/admin/admin_log.html
Show inline comments
 
@@ -6,6 +6,7 @@
 
		<td>${_('Repository')}</td>
 
		<td>${_('Action')}</td>
 
		<td>${_('Date')}</td>
 
		<td>${_('From IP')}</td>
 
	</tr>
 

	
 
	%for cnt,l in enumerate(c.users_log):
 
@@ -14,6 +15,7 @@
 
		<td>${l.repository}</td>
 
		<td>${l.action}</td>
 
		<td>${l.action_date}</td>
 
		<td>${l.user_ip}</td>
 
	</tr>
 
	%endfor
 

	
0 comments (0 inline, 0 general)