diff --git a/kallithea/controllers/admin/repo_groups.py b/kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py +++ b/kallithea/controllers/admin/repo_groups.py @@ -167,7 +167,7 @@ class RepoGroupsController(BaseControlle copy_permissions=form_result['group_copy_permissions'] ) Session().commit() - #TODO: in futureaction_logger(, '', '', '', self.sa) + #TODO: in future action_logger(, '', '', '') except formencode.Invalid as errors: return htmlfill.render( render('admin/repo_groups/repo_group_add.html'), @@ -234,7 +234,7 @@ class RepoGroupsController(BaseControlle % form_result['group_name'], category='success') # we now have new name ! group_name = new_gr.group_name - #TODO: in future action_logger(, '', '', '', self.sa) + #TODO: in future action_logger(, '', '', '') except formencode.Invalid as errors: c.active = 'settings' return htmlfill.render( @@ -271,7 +271,7 @@ class RepoGroupsController(BaseControlle Session().commit() h.flash(_('Removed repository group %s') % group_name, category='success') - #TODO: in future action_logger(, '', '', '', self.sa) + #TODO: in future action_logger(, '', '', '') except Exception: log.error(traceback.format_exc()) h.flash(_('Error occurred during deletion of repository group %s') @@ -372,7 +372,7 @@ class RepoGroupsController(BaseControlle recursive) #TODO: implement this #action_logger(request.authuser, 'admin_changed_repo_permissions', - # repo_name, request.ip_addr, self.sa) + # repo_name, request.ip_addr) Session().commit() h.flash(_('Repository group permissions updated'), category='success') raise HTTPFound(location=url('edit_repo_group_perms', group_name=group_name)) diff --git a/kallithea/controllers/admin/repos.py b/kallithea/controllers/admin/repos.py --- a/kallithea/controllers/admin/repos.py +++ b/kallithea/controllers/admin/repos.py @@ -241,7 +241,7 @@ class ReposController(BaseRepoController category='success') changed_name = repo.repo_name action_logger(request.authuser, 'admin_updated_repo', - changed_name, request.ip_addr, self.sa) + changed_name, request.ip_addr) Session().commit() except formencode.Invalid as errors: log.info(errors) @@ -282,7 +282,7 @@ class ReposController(BaseRepoController h.flash(_('Deleted %s forks') % _forks, category='success') repo_model.delete(repo, forks=handle_forks) action_logger(request.authuser, 'admin_deleted_repo', - repo_name, request.ip_addr, self.sa) + repo_name, request.ip_addr) ScmModel().mark_for_invalidation(repo_name) h.flash(_('Deleted repository %s') % repo_name, category='success') Session().commit() @@ -334,7 +334,7 @@ class ReposController(BaseRepoController form['perms_updates']) #TODO: implement this #action_logger(request.authuser, 'admin_changed_repo_permissions', - # repo_name, request.ip_addr, self.sa) + # repo_name, request.ip_addr) Session().commit() h.flash(_('Repository permissions updated'), category='success') raise HTTPFound(location=url('edit_repo_perms', repo_name=repo_name)) @@ -356,7 +356,7 @@ class ReposController(BaseRepoController ) #TODO: implement this #action_logger(request.authuser, 'admin_revoked_repo_permissions', - # repo_name, request.ip_addr, self.sa) + # repo_name, request.ip_addr) Session().commit() except Exception: log.error(traceback.format_exc()) diff --git a/kallithea/controllers/admin/user_groups.py b/kallithea/controllers/admin/user_groups.py --- a/kallithea/controllers/admin/user_groups.py +++ b/kallithea/controllers/admin/user_groups.py @@ -142,7 +142,7 @@ class UserGroupsController(BaseControlle gr = form_result['users_group_name'] action_logger(request.authuser, 'admin_created_users_group:%s' % gr, - None, request.ip_addr, self.sa) + None, request.ip_addr) h.flash(h.literal(_('Created user group %s') % h.link_to(h.escape(gr), url('edit_users_group', id=ug.users_group_id))), category='success') Session().commit() @@ -183,7 +183,7 @@ class UserGroupsController(BaseControlle gr = form_result['users_group_name'] action_logger(request.authuser, 'admin_updated_users_group:%s' % gr, - None, request.ip_addr, self.sa) + None, request.ip_addr) h.flash(_('Updated user group %s') % gr, category='success') Session().commit() except formencode.Invalid as errors: @@ -286,7 +286,7 @@ class UserGroupsController(BaseControlle raise HTTPFound(location=url('edit_user_group_perms', id=id)) #TODO: implement this #action_logger(request.authuser, 'admin_changed_repo_permissions', - # repo_name, request.ip_addr, self.sa) + # repo_name, request.ip_addr) Session().commit() h.flash(_('User group permissions updated'), category='success') raise HTTPFound(location=url('edit_user_group_perms', id=id)) diff --git a/kallithea/controllers/admin/users.py b/kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py +++ b/kallithea/controllers/admin/users.py @@ -122,7 +122,7 @@ class UsersController(BaseController): form_result = user_form.to_python(dict(request.POST)) user = user_model.create(form_result) action_logger(request.authuser, 'admin_created_user:%s' % user.username, - None, request.ip_addr, self.sa) + None, request.ip_addr) h.flash(_('Created user %s') % user.username, category='success') Session().commit() @@ -161,7 +161,7 @@ class UsersController(BaseController): user_model.update(id, form_result, skip_attrs=skip_attrs) usr = form_result['username'] action_logger(request.authuser, 'admin_updated_user:%s' % usr, - None, request.ip_addr, self.sa) + None, request.ip_addr) h.flash(_('User updated successfully'), category='success') Session().commit() except formencode.Invalid as errors: diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py +++ b/kallithea/controllers/changeset.py @@ -393,7 +393,7 @@ class ChangesetController(BaseRepoContro action_logger(request.authuser, 'user_commented_revision:%s' % revision, - c.db_repo, request.ip_addr, self.sa) + c.db_repo, request.ip_addr) Session().commit() diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -818,7 +818,7 @@ class PullrequestsController(BaseRepoCon action_logger(request.authuser, 'user_commented_pull_request:%s' % pull_request_id, - c.db_repo, request.ip_addr, self.sa) + c.db_repo, request.ip_addr) if status: ChangesetStatusModel().set_status( @@ -833,7 +833,7 @@ class PullrequestsController(BaseRepoCon PullRequestModel().close_pull_request(pull_request_id) action_logger(request.authuser, 'user_closed_pull_request:%s' % pull_request_id, - c.db_repo, request.ip_addr, self.sa) + c.db_repo, request.ip_addr) Session().commit() diff --git a/kallithea/lib/celerylib/tasks.py b/kallithea/lib/celerylib/tasks.py --- a/kallithea/lib/celerylib/tasks.py +++ b/kallithea/lib/celerylib/tasks.py @@ -373,7 +373,7 @@ def create_repo(form_data, cur_user): ) action_logger(cur_user, 'user_created_repo', - form_data['repo_name_full'], '', DBS) + form_data['repo_name_full'], '') DBS.commit() # now create this repo on Filesystem @@ -449,7 +449,7 @@ def create_repo_fork(form_data, cur_user copy_fork_permissions=copy_fork_permissions ) action_logger(cur_user, 'user_forked_repo:%s' % repo_name_full, - fork_of.repo_name, '', DBS) + fork_of.repo_name, '') DBS.commit() update_after_clone = form_data['update_after_clone'] # FIXME - unused! diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -137,7 +137,7 @@ def get_repo_by_id(repo_name): return None -def action_logger(user, action, repo, ipaddr='', sa=None, commit=False): +def action_logger(user, action, repo, ipaddr='', commit=False): """ Action logger for various actions made by users @@ -148,12 +148,9 @@ def action_logger(user, action, repo, ip :param repo: string name of repository or object containing repo_id, that action was made on :param ipaddr: optional IP address from what the action was made - :param sa: optional sqlalchemy session """ - if not sa: - sa = meta.Session() # if we don't get explicit IP address try to get one from registered user # in tmpl context var if not ipaddr: @@ -186,12 +183,12 @@ def action_logger(user, action, repo, ip user_log.action_date = datetime.datetime.now() user_log.user_ip = ipaddr - sa.add(user_log) + meta.Session().add(user_log) log.info('Logging action:%s on %s by user:%s ip:%s', action, safe_unicode(repo), user_obj, ipaddr) if commit: - sa.commit() + meta.Session().commit() def get_filesystem_repos(path):