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