Changeset - 5ee341209d7f
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 12 years ago 2013-06-15 22:51:32
marcin@python-works.com
action logger will try to get IP address automatically based
on tmpl_context var (if defined)
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/utils.py
Show inline comments
 
@@ -145,12 +145,17 @@ def action_logger(user, action, repo, ip
 
    :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
 
    from pylons import tmpl_context
 
    if not ipaddr and hasattr(tmpl_context, 'rhodecode_user'):
 
        ipaddr = tmpl_context.rhodecode_user.ip_addr
 

	
 
    try:
 
        if hasattr(user, 'user_id'):
 
            user_obj = User.get(user.user_id)
 
        elif isinstance(user, basestring):
 
            user_obj = User.get_by_username(user)
0 comments (0 inline, 0 general)