Show More
@@ -13,29 +13,34 b' import traceback' | |||
|
13 | 13 | |
|
14 | 14 | try: |
|
15 | 15 | from celeryconfig import PYLONS_CONFIG as config |
|
16 | celery_on = True | |
|
16 | 17 | except ImportError: |
|
17 | 18 | #if celeryconfig is not present let's just load our pylons |
|
18 | 19 | #config instead |
|
19 | 20 | from pylons import config |
|
21 | celery_on = False | |
|
20 | 22 | |
|
21 | 23 | |
|
22 | 24 | __all__ = ['whoosh_index', 'get_commits_stats', |
|
23 | 25 | 'reset_user_password', 'send_email'] |
|
24 | 26 | |
|
25 | 27 | def get_session(): |
|
26 | from sqlalchemy import engine_from_config | |
|
27 | from sqlalchemy.orm import sessionmaker, scoped_session | |
|
28 | engine = engine_from_config(dict(config.items('app:main')), 'sqlalchemy.db1.') | |
|
29 | sa = scoped_session(sessionmaker(bind=engine)) | |
|
28 | if celery_on: | |
|
29 | from sqlalchemy import engine_from_config | |
|
30 | from sqlalchemy.orm import sessionmaker, scoped_session | |
|
31 | engine = engine_from_config(dict(config.items('app:main')), 'sqlalchemy.db1.') | |
|
32 | sa = scoped_session(sessionmaker(bind=engine)) | |
|
33 | else: | |
|
34 | #If we don't use celery reuse our current application Session | |
|
35 | from rhodecode.model.meta import Session | |
|
36 | sa = Session | |
|
37 | ||
|
30 | 38 | return sa |
|
31 | 39 | |
|
32 | 40 | def get_hg_settings(): |
|
33 | 41 | from rhodecode.model.db import RhodeCodeSettings |
|
34 | try: | |
|
35 | sa = get_session() | |
|
36 | ret = sa.query(RhodeCodeSettings).all() | |
|
37 | finally: | |
|
38 | sa.remove() | |
|
42 | sa = get_session() | |
|
43 | ret = sa.query(RhodeCodeSettings).all() | |
|
39 | 44 | |
|
40 | 45 | if not ret: |
|
41 | 46 | raise Exception('Could not get application settings !') |
@@ -47,11 +52,8 b' def get_hg_settings():' | |||
|
47 | 52 | |
|
48 | 53 | def get_hg_ui_settings(): |
|
49 | 54 | from rhodecode.model.db import RhodeCodeUi |
|
50 | try: | |
|
51 | sa = get_session() | |
|
52 | ret = sa.query(RhodeCodeUi).all() | |
|
53 | finally: | |
|
54 | sa.remove() | |
|
55 | sa = get_session() | |
|
56 | ret = sa.query(RhodeCodeUi).all() | |
|
55 | 57 | |
|
56 | 58 | if not ret: |
|
57 | 59 | raise Exception('Could not get application ui settings !') |
General Comments 0
You need to be logged in to leave comments.
Login now