Mercurial > kallithea
diff pylons_app/lib/middleware/simplehg.py @ 536:39203995f2c4
made action logger more global, to be used in other places to log other actions.
cleaned unused import in simpleHG, fixed little logging in hooks
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 02 Oct 2010 01:52:43 +0200 |
parents | 3d6d548ad3cc |
children |
line wrap: on
line diff
--- a/pylons_app/lib/middleware/simplehg.py Fri Oct 01 03:04:52 2010 +0200 +++ b/pylons_app/lib/middleware/simplehg.py Sat Oct 02 01:52:43 2010 +0200 @@ -24,7 +24,6 @@ SimpleHG middleware for handling mercurial protocol request (push/clone etc.) It's implemented with basic auth function """ -from datetime import datetime from itertools import chain from mercurial.error import RepoError from mercurial.hgweb import hgweb @@ -35,12 +34,10 @@ get_user_cached from pylons_app.lib.utils import is_mercurial, make_ui, invalidate_cache, \ check_repo_fast, ui_sections -from pylons_app.model import meta -from pylons_app.model.db import UserLog, User from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError +from pylons_app.lib.utils import action_logger import logging import os -import pylons_app.lib.helpers as h import traceback log = logging.getLogger(__name__) @@ -183,23 +180,7 @@ return mapping[cmd] def __log_user_action(self, user, action, repo, ipaddr): - sa = meta.Session - try: - user_log = UserLog() - user_log.user_id = user.user_id - 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', - user.username, action, repo) - except Exception, e: - sa.rollback() - log.error('could not log user action:%s', str(e)) - finally: - meta.Session.remove() + action_logger(user, action, repo, ipaddr) def __invalidate_cache(self, repo_name): """we know that some change was made to repositories and we should