Changeset - 99c70e97ce48
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 14 years ago 2011-12-21 01:47:39
marcin@python-works.com
fixes issue with unbound session, thanks to slafs for patch
1 file changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/celerylib/tasks.py
Show inline comments
 
@@ -55,8 +55,6 @@ from sqlalchemy import engine_from_confi
 

	
 
add_cache(config)
 

	
 

	
 

	
 
__all__ = ['whoosh_index', 'get_commits_stats',
 
           'reset_user_password', 'send_email']
 

	
 
@@ -67,6 +65,7 @@ def get_session():
 
    if CELERY_ON:
 
        engine = engine_from_config(config, 'sqlalchemy.db1.')
 
        init_model(engine)
 

	
 
    sa = meta.Session()
 
    return sa
 

	
 
@@ -343,11 +342,14 @@ def send_email(recipients, subject, body
 
    except:
 
        log = logging.getLogger(__name__)
 

	
 
    sa = get_session()
 
    email_config = config
 

	
 
    if not recipients:
 
        # if recipients are not defined we send to email_config + all admins
 
        admins = [u.email for u in User.query().filter(User.admin==True).all()]
 
        admins = [
 
            u.email for u in sa.query(User).filter(User.admin==True).all()
 
        ]
 
        recipients = [email_config.get('email_to')] + admins
 

	
 
    mail_from = email_config.get('app_email_from')
0 comments (0 inline, 0 general)