##// END OF EJS Templates
fixes issue with unbound session, thanks to slafs for patch
marcink -
r1799:99c70e97 default
parent child Browse files
Show More
@@ -55,8 +55,6 from sqlalchemy import engine_from_confi
55
55
56 add_cache(config)
56 add_cache(config)
57
57
58
59
60 __all__ = ['whoosh_index', 'get_commits_stats',
58 __all__ = ['whoosh_index', 'get_commits_stats',
61 'reset_user_password', 'send_email']
59 'reset_user_password', 'send_email']
62
60
@@ -67,6 +65,7 def get_session():
67 if CELERY_ON:
65 if CELERY_ON:
68 engine = engine_from_config(config, 'sqlalchemy.db1.')
66 engine = engine_from_config(config, 'sqlalchemy.db1.')
69 init_model(engine)
67 init_model(engine)
68
70 sa = meta.Session()
69 sa = meta.Session()
71 return sa
70 return sa
72
71
@@ -103,7 +102,7 def get_commits_stats(repo_name, ts_min_
103 try:
102 try:
104 lock = l = DaemonLock(file_=jn(lockkey_path, lockkey))
103 lock = l = DaemonLock(file_=jn(lockkey_path, lockkey))
105
104
106 #for js data compatibilty cleans the key for person from '
105 # for js data compatibilty cleans the key for person from '
107 akc = lambda k: person(k).replace('"', "")
106 akc = lambda k: person(k).replace('"', "")
108
107
109 co_day_auth_aggr = {}
108 co_day_auth_aggr = {}
@@ -236,10 +235,10 def get_commits_stats(repo_name, ts_min_
236 lock.release()
235 lock.release()
237 return False
236 return False
238
237
239 #final release
238 # final release
240 lock.release()
239 lock.release()
241
240
242 #execute another task if celery is enabled
241 # execute another task if celery is enabled
243 if len(repo.revisions) > 1 and CELERY_ON:
242 if len(repo.revisions) > 1 and CELERY_ON:
244 run_task(get_commits_stats, repo_name, ts_min_y, ts_max_y)
243 run_task(get_commits_stats, repo_name, ts_min_y, ts_max_y)
245 return True
244 return True
@@ -342,12 +341,15 def send_email(recipients, subject, body
342 log = send_email.get_logger()
341 log = send_email.get_logger()
343 except:
342 except:
344 log = logging.getLogger(__name__)
343 log = logging.getLogger(__name__)
345
344
345 sa = get_session()
346 email_config = config
346 email_config = config
347
347
348 if not recipients:
348 if not recipients:
349 # if recipients are not defined we send to email_config + all admins
349 # if recipients are not defined we send to email_config + all admins
350 admins = [u.email for u in User.query().filter(User.admin==True).all()]
350 admins = [
351 u.email for u in sa.query(User).filter(User.admin==True).all()
352 ]
351 recipients = [email_config.get('email_to')] + admins
353 recipients = [email_config.get('email_to')] + admins
352
354
353 mail_from = email_config.get('app_email_from')
355 mail_from = email_config.get('app_email_from')
General Comments 0
You need to be logged in to leave comments. Login now