##// END OF EJS Templates
fixed Example celery config to ampq,...
marcink -
r752:89b9037d beta
parent child Browse files
Show More
@@ -14,8 +14,10 b' PYLONS_CONFIG = config'
14 14 CELERY_IMPORTS = ("rhodecode.lib.celerylib.tasks",)
15 15
16 16 ## Result store settings.
17 CELERY_RESULT_BACKEND = "database"
18 CELERY_RESULT_DBURI = dict(config.items('app:main'))['sqlalchemy.db1.url']
17 CELERY_RESULT_BACKEND = "amqp"
18 CELERY_AMQP_TASK_RESULT_EXPIRES = 18000 # 5 hours.
19
20 #CELERY_RESULT_DBURI = dict(config.items('app:main'))['sqlalchemy.db1.url']
19 21 CELERY_RESULT_SERIALIZER = 'json'
20 22
21 23
@@ -280,7 +280,7 b' def create_repo_fork(form_data, cur_user'
280 280 from rhodecode.model.repo import RepoModel
281 281 from vcs import get_backend
282 282 log = create_repo_fork.get_logger()
283 repo_model = RepoModel()
283 repo_model = RepoModel(get_session())
284 284 repo_model.create(form_data, cur_user, just_db=True, fork=True)
285 285 repo_name = form_data['repo_name']
286 286 repos_path = get_repos_path()
@@ -21,3 +21,12 b' def init_model(engine):'
21 21 #engine = engine_from_config(config, 'sqlalchemy.')
22 22 #init_model(engine)
23 23 # DO SOMETHING
24
25
26 class BaseModel(object):
27
28 def __init__(self, sa=None):
29 if sa is not None:
30 self.sa = sa
31 else:
32 self.sa = meta.Session()
@@ -20,21 +20,18 b''
20 20 """
21 21 Created on Aug 20, 2010
22 22 Model for permissions
23 @author: marcink
23 :author: marcink
24 24 """
25 25
26 from rhodecode.model import BaseModel
26 27 from rhodecode.model.db import User, Permission, UserToPerm, RepoToPerm
27 28 from rhodecode.model.caching_query import FromCache
28 from rhodecode.model.meta import Session
29 29 import logging
30 30 import traceback
31 31 log = logging.getLogger(__name__)
32 32
33 33
34 class PermissionModel(object):
35
36 def __init__(self):
37 self.sa = Session()
34 class PermissionModel(BaseModel):
38 35
39 36 def get_permission(self, permission_id, cache=False):
40 37 perm = self.sa.query(Permission)
@@ -21,12 +21,12 b' Created on Jun 5, 2010'
21 21 model for handling repositories actions
22 22 :author: marcink
23 23 """
24 from vcs.backends import get_repo, get_backend
24 from vcs.backends import get_backend
25 25 from datetime import datetime
26 26 from pylons import app_globals as g
27 27 from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \
28 28 Statistics
29 from rhodecode.model.meta import Session
29 from rhodecode.model import BaseModel
30 30 from rhodecode.model.user import UserModel
31 31 from rhodecode.model.caching_query import FromCache
32 32 import logging
@@ -35,10 +35,7 b' import shutil'
35 35 import traceback
36 36 log = logging.getLogger(__name__)
37 37
38 class RepoModel(object):
39
40 def __init__(self):
41 self.sa = Session()
38 class RepoModel(BaseModel):
42 39
43 40 def get(self, repo_id, cache=False):
44 41 repo = self.sa.query(Repository)\
@@ -57,7 +54,7 b' class RepoModel(object):'
57 54 if cache:
58 55 repo = repo.options(FromCache("sql_cache_short",
59 56 "get_repo_%s" % repo_name))
60 return repo.scalar()
57 return repo.scalar()
61 58
62 59 def get_users_js(self):
63 60
@@ -75,14 +72,14 b' class RepoModel(object):'
75 72 #update permissions
76 73 for username, perm in form_data['perms_updates']:
77 74 r2p = self.sa.query(RepoToPerm)\
78 .filter(RepoToPerm.user == UserModel()\
75 .filter(RepoToPerm.user == UserModel(self.sa)\
79 76 .get_by_username(username, cache=False))\
80 77 .filter(RepoToPerm.repository == \
81 78 self.get_by_repo_name(repo_name))\
82 79 .one()
83 80
84 81 r2p.permission_id = self.sa.query(Permission).filter(
85 Permission.permission_name ==
82 Permission.permission_name ==
86 83 perm).one().permission_id
87 84 self.sa.add(r2p)
88 85
@@ -90,7 +87,7 b' class RepoModel(object):'
90 87 for username, perm in form_data['perms_new']:
91 88 r2p = RepoToPerm()
92 89 r2p.repository = self.get_by_repo_name(repo_name)
93 r2p.user = UserModel().get_by_username(username, cache=False)
90 r2p.user = UserModel(self.sa).get_by_username(username, cache=False)
94 91
95 92 r2p.permission_id = self.sa.query(Permission).filter(
96 93 Permission.permission_name == perm)\
@@ -144,7 +141,7 b' class RepoModel(object):'
144 141 #create default permission
145 142 repo_to_perm = RepoToPerm()
146 143 default = 'repository.read'
147 for p in UserModel().get_by_username('default', cache=False).user_perms:
144 for p in UserModel(self.sa).get_by_username('default', cache=False).user_perms:
148 145 if p.permission.permission_name.startswith('repository.'):
149 146 default = p.permission.permission_name
150 147 break
@@ -156,7 +153,8 b' class RepoModel(object):'
156 153 .one().permission_id
157 154
158 155 repo_to_perm.repository_id = new_repo.repo_id
159 repo_to_perm.user_id = UserModel().get_by_username('default', cache=False).user_id
156 repo_to_perm.user_id = UserModel(self.sa)\
157 .get_by_username('default', cache=False).user_id
160 158
161 159 self.sa.add(repo_to_perm)
162 160 self.sa.commit()
@@ -28,7 +28,7 b' from rhodecode import BACKENDS'
28 28 from rhodecode.lib import helpers as h
29 29 from rhodecode.lib.auth import HasRepoPermissionAny
30 30 from rhodecode.lib.utils import get_repos, make_ui, action_logger
31 from rhodecode.model import meta
31 from rhodecode.model import BaseModel
32 32 from rhodecode.model.db import Repository, User, RhodeCodeUi, CacheInvalidation, \
33 33 UserFollowing
34 34 from rhodecode.model.caching_query import FromCache
@@ -54,14 +54,11 b' class RepoTemp(object):'
54 54 self.repo_id = repo_id
55 55
56 56
57 class ScmModel(object):
57 class ScmModel(BaseModel):
58 58 """
59 59 Mercurial Model
60 60 """
61 61
62 def __init__(self):
63 self.sa = meta.Session()
64
65 62 @LazyProperty
66 63 def repos_path(self):
67 64 """
@@ -20,10 +20,11 b''
20 20 """
21 21 Created on Nov 17, 2010
22 22 Model for RhodeCode
23 @author: marcink
23 :author: marcink
24 24 """
25
25 26 from rhodecode.lib import helpers as h
26 from rhodecode.model import meta
27 from rhodecode.model import BaseModel
27 28 from rhodecode.model.caching_query import FromCache
28 29 from rhodecode.model.db import RhodeCodeSettings
29 30 from sqlalchemy.orm import joinedload
@@ -32,15 +33,11 b' import logging'
32 33
33 34 log = logging.getLogger(__name__)
34 35
35 class SettingsModel(object):
36 class SettingsModel(BaseModel):
36 37 """
37 38 Settings model
38 39 """
39 40
40 def __init__(self):
41 self.sa = meta.Session()
42
43
44 41 def get(self, settings_key, cache=False):
45 42 r = self.sa.query(RhodeCodeSettings)\
46 43 .filter(RhodeCodeSettings.app_settings_name == settings_key).scalar()
@@ -24,9 +24,9 b' Model for users'
24 24 """
25 25
26 26 from pylons.i18n.translation import _
27 from rhodecode.model import BaseModel
27 28 from rhodecode.model.caching_query import FromCache
28 29 from rhodecode.model.db import User
29 from rhodecode.model.meta import Session
30 30 from rhodecode.lib.exceptions import *
31 31
32 32 import logging
@@ -36,10 +36,7 b' log = logging.getLogger(__name__)'
36 36
37 37
38 38
39 class UserModel(object):
40
41 def __init__(self):
42 self.sa = Session()
39 class UserModel(BaseModel):
43 40
44 41 def get(self, user_id, cache=False):
45 42 user = self.sa.query(User)
General Comments 0
You need to be logged in to leave comments. Login now