##// END OF EJS Templates
Code refactoring,models renames...
marcink -
r629:7e536d1a beta
parent child Browse files
Show More
@@ -6,7 +6,7 from rhodecode.config.routing import mak
6 from rhodecode.lib.auth import set_available_permissions, set_base_path
6 from rhodecode.lib.auth import set_available_permissions, set_base_path
7 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config
7 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config
8 from rhodecode.model import init_model
8 from rhodecode.model import init_model
9 from rhodecode.model.hg_model import _get_repos_cached_initial
9 from rhodecode.model.hg import _get_repos_cached_initial
10 from sqlalchemy import engine_from_config
10 from sqlalchemy import engine_from_config
11 import logging
11 import logging
12 import os
12 import os
@@ -30,10 +30,9 from pylons.i18n.translation import _
30 from rhodecode.lib import helpers as h
30 from rhodecode.lib import helpers as h
31 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
31 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
32 from rhodecode.lib.base import BaseController, render
32 from rhodecode.lib.base import BaseController, render
33 from rhodecode.model.db import User, UserLog
34 from rhodecode.model.forms import UserForm, DefaultPermissionsForm
33 from rhodecode.model.forms import UserForm, DefaultPermissionsForm
35 from rhodecode.model.permission_model import PermissionModel
34 from rhodecode.model.permission_model import PermissionModel
36 from rhodecode.model.user_model import UserModel
35 from rhodecode.model.user import UserModel
37 import formencode
36 import formencode
38 import logging
37 import logging
39 import traceback
38 import traceback
@@ -35,8 +35,8 from rhodecode.lib.base import BaseContr
35 from rhodecode.lib.utils import invalidate_cache, action_logger
35 from rhodecode.lib.utils import invalidate_cache, action_logger
36 from rhodecode.model.db import User
36 from rhodecode.model.db import User
37 from rhodecode.model.forms import RepoForm
37 from rhodecode.model.forms import RepoForm
38 from rhodecode.model.hg_model import HgModel
38 from rhodecode.model.hg import HgModel
39 from rhodecode.model.repo_model import RepoModel
39 from rhodecode.model.repo import RepoModel
40 import formencode
40 import formencode
41 import logging
41 import logging
42 import traceback
42 import traceback
@@ -32,12 +32,12 from rhodecode.lib.auth import LoginRequ
32 HasPermissionAnyDecorator
32 HasPermissionAnyDecorator
33 from rhodecode.lib.base import BaseController, render
33 from rhodecode.lib.base import BaseController, render
34 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
34 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
35 set_rhodecode_config, get_hg_settings, get_hg_ui_settings, make_ui
35 set_rhodecode_config, get_hg_settings, get_hg_ui_settings
36 from rhodecode.model.db import User, UserLog, RhodeCodeSettings, RhodeCodeUi
36 from rhodecode.model.db import RhodeCodeSettings, RhodeCodeUi
37 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
37 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
38 ApplicationUiSettingsForm
38 ApplicationUiSettingsForm
39 from rhodecode.model.hg_model import HgModel
39 from rhodecode.model.hg import HgModel
40 from rhodecode.model.user_model import UserModel
40 from rhodecode.model.user import UserModel
41 from rhodecode.lib.celerylib import tasks, run_task
41 from rhodecode.lib.celerylib import tasks, run_task
42 import formencode
42 import formencode
43 import logging
43 import logging
@@ -231,7 +231,7 class SettingsController(BaseController)
231 GET /_admin/my_account Displays info about my account
231 GET /_admin/my_account Displays info about my account
232 """
232 """
233 # url('admin_settings_my_account')
233 # url('admin_settings_my_account')
234 c.user = self.sa.query(User).get(c.rhodecode_user.user_id)
234 c.user = UserModel(self.sa).get(c.rhodecode_user.user_id, cache=False)
235 c.user_repos = []
235 c.user_repos = []
236 for repo in c.cached_repo_list.values():
236 for repo in c.cached_repo_list.values():
237 if repo.dbrepo.user.username == c.user.username:
237 if repo.dbrepo.user.username == c.user.username:
@@ -270,7 +270,7 class SettingsController(BaseController)
270 category='success')
270 category='success')
271
271
272 except formencode.Invalid, errors:
272 except formencode.Invalid, errors:
273 c.user = self.sa.query(User).get(c.rhodecode_user.user_id)
273 c.user = user_model.get(c.rhodecode_user.user_id, cache=False)
274 c.user_repos = []
274 c.user_repos = []
275 for repo in c.cached_repo_list.values():
275 for repo in c.cached_repo_list.values():
276 if repo.dbrepo.user.username == c.user.username:
276 if repo.dbrepo.user.username == c.user.username:
@@ -33,7 +33,7 from rhodecode.lib.auth import LoginRequ
33 from rhodecode.lib.base import BaseController, render
33 from rhodecode.lib.base import BaseController, render
34 from rhodecode.model.db import User, UserLog
34 from rhodecode.model.db import User, UserLog
35 from rhodecode.model.forms import UserForm
35 from rhodecode.model.forms import UserForm
36 from rhodecode.model.user_model import UserModel, DefaultUserException
36 from rhodecode.model.user import UserModel, DefaultUserException
37 import formencode
37 import formencode
38 import logging
38 import logging
39 import traceback
39 import traceback
@@ -100,7 +100,7 class UsersController(BaseController):
100 # method='put')
100 # method='put')
101 # url('user', id=ID)
101 # url('user', id=ID)
102 user_model = UserModel()
102 user_model = UserModel()
103 c.user = user_model.get_user(id)
103 c.user = user_model.get(id)
104
104
105 _form = UserForm(edit=True, old_data={'user_id':id,
105 _form = UserForm(edit=True, old_data={'user_id':id,
106 'email':c.user.email})()
106 'email':c.user.email})()
@@ -26,7 +26,7 from pylons import tmpl_context as c
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
27 from rhodecode.lib.base import BaseController, render
28 from rhodecode.lib.utils import OrderedDict
28 from rhodecode.lib.utils import OrderedDict
29 from rhodecode.model.hg_model import HgModel
29 from rhodecode.model.hg import HgModel
30 import logging
30 import logging
31 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
32
32
@@ -32,7 +32,7 from mercurial.graphmod import colored,
32 from pylons import request, session, tmpl_context as c
32 from pylons import request, session, tmpl_context as c
33 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
33 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
34 from rhodecode.lib.base import BaseController, render
34 from rhodecode.lib.base import BaseController, render
35 from rhodecode.model.hg_model import HgModel
35 from rhodecode.model.hg import HgModel
36 from webhelpers.paginate import Page
36 from webhelpers.paginate import Page
37 import logging
37 import logging
38 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
@@ -27,7 +27,7 from pylons.i18n.translation import _
27 from pylons.controllers.util import redirect
27 from pylons.controllers.util import redirect
28 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
28 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
29 from rhodecode.lib.base import BaseController, render
29 from rhodecode.lib.base import BaseController, render
30 from rhodecode.model.hg_model import HgModel
30 from rhodecode.model.hg import HgModel
31 from vcs.exceptions import RepositoryError, ChangesetError
31 from vcs.exceptions import RepositoryError, ChangesetError
32 from vcs.nodes import FileNode
32 from vcs.nodes import FileNode
33 from vcs.utils import diffs as differ
33 from vcs.utils import diffs as differ
@@ -24,7 +24,7 feed controller for pylons
24 """
24 """
25 from pylons import tmpl_context as c, url, response
25 from pylons import tmpl_context as c, url, response
26 from rhodecode.lib.base import BaseController, render
26 from rhodecode.lib.base import BaseController, render
27 from rhodecode.model.hg_model import HgModel
27 from rhodecode.model.hg import HgModel
28 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
28 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
29 import logging
29 import logging
30 log = logging.getLogger(__name__)
30 log = logging.getLogger(__name__)
@@ -29,7 +29,7 from pylons.controllers.util import redi
29 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
29 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
30 from rhodecode.lib.base import BaseController, render
30 from rhodecode.lib.base import BaseController, render
31 from rhodecode.lib.utils import EmptyChangeset
31 from rhodecode.lib.utils import EmptyChangeset
32 from rhodecode.model.hg_model import HgModel
32 from rhodecode.model.hg import HgModel
33 from vcs.exceptions import RepositoryError, ChangesetError
33 from vcs.exceptions import RepositoryError, ChangesetError
34 from vcs.nodes import FileNode
34 from vcs.nodes import FileNode
35 from vcs.utils import diffs as differ
35 from vcs.utils import diffs as differ
@@ -26,7 +26,7 from operator import itemgetter
26 from pylons import tmpl_context as c, request
26 from pylons import tmpl_context as c, request
27 from rhodecode.lib.auth import LoginRequired
27 from rhodecode.lib.auth import LoginRequired
28 from rhodecode.lib.base import BaseController, render
28 from rhodecode.lib.base import BaseController, render
29 from rhodecode.model.hg_model import HgModel
29 from rhodecode.model.hg import HgModel
30 import logging
30 import logging
31 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
32
32
@@ -31,7 +31,7 from rhodecode.lib.base import BaseContr
31 import rhodecode.lib.helpers as h
31 import rhodecode.lib.helpers as h
32 from pylons.i18n.translation import _
32 from pylons.i18n.translation import _
33 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
33 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
34 from rhodecode.model.user_model import UserModel
34 from rhodecode.model.user import UserModel
35 import formencode
35 import formencode
36 import logging
36 import logging
37
37
@@ -55,7 +55,7 class LoginController(BaseController):
55 try:
55 try:
56 c.form_result = login_form.to_python(dict(request.POST))
56 c.form_result = login_form.to_python(dict(request.POST))
57 username = c.form_result['username']
57 username = c.form_result['username']
58 user = UserModel().get_user_by_name(username)
58 user = UserModel().get_by_username(username)
59 auth_user = AuthUser()
59 auth_user = AuthUser()
60 auth_user.username = user.username
60 auth_user.username = user.username
61 auth_user.is_authenticated = True
61 auth_user.is_authenticated = True
@@ -89,7 +89,7 class LoginController(BaseController):
89 def register(self):
89 def register(self):
90 user_model = UserModel()
90 user_model = UserModel()
91 c.auto_active = False
91 c.auto_active = False
92 for perm in user_model.get_default().user_perms:
92 for perm in user_model.get_by_username('default', cache=False).user_perms:
93 if perm.permission.permission_name == 'hg.register.auto_activate':
93 if perm.permission.permission_name == 'hg.register.auto_activate':
94 c.auto_active = True
94 c.auto_active = True
95 break
95 break
@@ -30,7 +30,7 from rhodecode.lib.auth import LoginRequ
30 from rhodecode.lib.base import BaseController, render
30 from rhodecode.lib.base import BaseController, render
31 from rhodecode.lib.utils import invalidate_cache, action_logger
31 from rhodecode.lib.utils import invalidate_cache, action_logger
32 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
32 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
33 from rhodecode.model.repo_model import RepoModel
33 from rhodecode.model.repo import RepoModel
34 import formencode
34 import formencode
35 import logging
35 import logging
36 import rhodecode.lib.helpers as h
36 import rhodecode.lib.helpers as h
@@ -25,7 +25,7 shortlog controller for pylons
25 from pylons import tmpl_context as c, request
25 from pylons import tmpl_context as c, request
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
27 from rhodecode.lib.base import BaseController, render
28 from rhodecode.model.hg_model import HgModel
28 from rhodecode.model.hg import HgModel
29 from webhelpers.paginate import Page
29 from webhelpers.paginate import Page
30 import logging
30 import logging
31 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
@@ -26,7 +26,7 from pylons import tmpl_context as c, re
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
27 from rhodecode.lib.base import BaseController, render
28 from rhodecode.lib.utils import OrderedDict
28 from rhodecode.lib.utils import OrderedDict
29 from rhodecode.model.hg_model import HgModel
29 from rhodecode.model.hg import HgModel
30 from rhodecode.model.db import Statistics
30 from rhodecode.model.db import Statistics
31 from webhelpers.paginate import Page
31 from webhelpers.paginate import Page
32 from rhodecode.lib.celerylib import run_task
32 from rhodecode.lib.celerylib import run_task
@@ -26,7 +26,7 from pylons import tmpl_context as c
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
26 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 from rhodecode.lib.base import BaseController, render
27 from rhodecode.lib.base import BaseController, render
28 from rhodecode.lib.utils import OrderedDict
28 from rhodecode.lib.utils import OrderedDict
29 from rhodecode.model.hg_model import HgModel
29 from rhodecode.model.hg import HgModel
30 import logging
30 import logging
31 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
32
32
@@ -22,7 +22,6 Created on April 4, 2010
22
22
23 @author: marcink
23 @author: marcink
24 """
24 """
25 from beaker.cache import cache_region
26 from pylons import config, session, url, request
25 from pylons import config, session, url, request
27 from pylons.controllers.util import abort, redirect
26 from pylons.controllers.util import abort, redirect
28 from rhodecode.lib.utils import get_repo_slug
27 from rhodecode.lib.utils import get_repo_slug
@@ -30,8 +29,6 from rhodecode.model import meta
30 from rhodecode.model.caching_query import FromCache
29 from rhodecode.model.caching_query import FromCache
31 from rhodecode.model.db import User, RepoToPerm, Repository, Permission, \
30 from rhodecode.model.db import User, RepoToPerm, Repository, Permission, \
32 UserToPerm
31 UserToPerm
33 from sqlalchemy.exc import OperationalError
34 from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
35 import bcrypt
32 import bcrypt
36 from decorator import decorator
33 from decorator import decorator
37 import logging
34 import logging
@@ -74,21 +71,9 def get_crypt_password(password):
74 def check_password(password, hashed):
71 def check_password(password, hashed):
75 return bcrypt.hashpw(password, hashed) == hashed
72 return bcrypt.hashpw(password, hashed) == hashed
76
73
77 @cache_region('super_short_term', 'cached_user')
78 def get_user_cached(username):
79 sa = meta.Session
80 try:
81 user = sa.query(User).filter(User.username == username).one()
82 finally:
83 meta.Session.remove()
84 return user
85
86 def authfunc(environ, username, password):
74 def authfunc(environ, username, password):
87 try:
75 from rhodecode.model.user import UserModel
88 user = get_user_cached(username)
76 user = UserModel().get_by_username(username, cache=False)
89 except (NoResultFound, MultipleResultsFound, OperationalError), e:
90 log.error(e)
91 user = None
92
77
93 if user:
78 if user:
94 if user.active:
79 if user.active:
@@ -125,8 +110,10 def set_available_permissions(config):
125 """
110 """
126 log.info('getting information about all available permissions')
111 log.info('getting information about all available permissions')
127 try:
112 try:
128 sa = meta.Session
113 sa = meta.Session()
129 all_perms = sa.query(Permission).all()
114 all_perms = sa.query(Permission).all()
115 except:
116 pass
130 finally:
117 finally:
131 meta.Session.remove()
118 meta.Session.remove()
132
119
@@ -141,10 +128,16 def fill_data(user):
141 in database
128 in database
142 :param user:
129 :param user:
143 """
130 """
144 sa = meta.Session
131 sa = meta.Session()
145 dbuser = sa.query(User).options(FromCache('sql_cache_short',
132 try:
146 'getuser_%s' % user.user_id))\
133 dbuser = sa.query(User)\
134 .options(FromCache('sql_cache_short', 'getuser_%s' % user.user_id))\
147 .get(user.user_id)
135 .get(user.user_id)
136 except:
137 pass
138 finally:
139 meta.Session.remove()
140
148 if dbuser:
141 if dbuser:
149 user.username = dbuser.username
142 user.username = dbuser.username
150 user.is_admin = dbuser.admin
143 user.is_admin = dbuser.admin
@@ -153,7 +146,8 def fill_data(user):
153 user.email = dbuser.email
146 user.email = dbuser.email
154 else:
147 else:
155 user.is_authenticated = False
148 user.is_authenticated = False
156 meta.Session.remove()
149
150
157 return user
151 return user
158
152
159 def fill_perms(user):
153 def fill_perms(user):
@@ -162,7 +156,7 def fill_perms(user):
162 :param user:
156 :param user:
163 """
157 """
164
158
165 sa = meta.Session
159 sa = meta.Session()
166 user.permissions['repositories'] = {}
160 user.permissions['repositories'] = {}
167 user.permissions['global'] = set()
161 user.permissions['global'] = set()
168
162
@@ -9,7 +9,7 from rhodecode import __version__
9 from rhodecode.lib import auth
9 from rhodecode.lib import auth
10 from rhodecode.lib.utils import get_repo_slug
10 from rhodecode.lib.utils import get_repo_slug
11 from rhodecode.model import meta
11 from rhodecode.model import meta
12 from rhodecode.model.hg_model import _get_repos_cached, \
12 from rhodecode.model.hg import _get_repos_cached, \
13 _get_repos_switcher_cached
13 _get_repos_switcher_cached
14
14
15 class BaseController(WSGIController):
15 class BaseController(WSGIController):
@@ -31,7 +31,7 class BaseController(WSGIController):
31 c.repository_tags = {}
31 c.repository_tags = {}
32 c.repository_branches = {}
32 c.repository_branches = {}
33
33
34 self.sa = meta.Session
34 self.sa = meta.Session()
35
35
36 def __call__(self, environ, start_response):
36 def __call__(self, environ, start_response):
37 """Invoke the Controller"""
37 """Invoke the Controller"""
@@ -38,7 +38,7 def get_session():
38 else:
38 else:
39 #If we don't use celery reuse our current application Session
39 #If we don't use celery reuse our current application Session
40 from rhodecode.model.meta import Session
40 from rhodecode.model.meta import Session
41 sa = Session
41 sa = Session()
42
42
43 return sa
43 return sa
44
44
@@ -285,7 +285,7 def send_email(recipients, subject, body
285 @task
285 @task
286 def create_repo_fork(form_data, cur_user):
286 def create_repo_fork(form_data, cur_user):
287 import os
287 import os
288 from rhodecode.model.repo_model import RepoModel
288 from rhodecode.model.repo import RepoModel
289 sa = get_session()
289 sa = get_session()
290 rm = RepoModel(sa)
290 rm = RepoModel(sa)
291
291
@@ -48,7 +48,7 class DbManage(object):
48 dburi = 'sqlite:////%s' % jn(self.root, self.dbname)
48 dburi = 'sqlite:////%s' % jn(self.root, self.dbname)
49 engine = create_engine(dburi, echo=log_sql)
49 engine = create_engine(dburi, echo=log_sql)
50 init_model(engine)
50 init_model(engine)
51 self.sa = meta.Session
51 self.sa = meta.Session()
52 self.db_exists = False
52 self.db_exists = False
53
53
54 def check_for_db(self, override):
54 def check_for_db(self, override):
@@ -59,7 +59,7 def user_action_mapper(ui, repo, hooktyp
59 """
59 """
60
60
61 try:
61 try:
62 sa = meta.Session
62 sa = meta.Session()
63 username = kwargs['url'].split(':')[-1]
63 username = kwargs['url'].split(':')[-1]
64 user_log = sa.query(UserLog)\
64 user_log = sa.query(UserLog)\
65 .filter(UserLog.user == sa.query(User)\
65 .filter(UserLog.user == sa.query(User)\
@@ -1,6 +1,6
1 from os.path import dirname as dn, join as jn
1 from os.path import dirname as dn, join as jn
2 from rhodecode.config.environment import load_environment
2 from rhodecode.config.environment import load_environment
3 from rhodecode.model.hg_model import HgModel
3 from rhodecode.model.hg import HgModel
4 from shutil import rmtree
4 from shutil import rmtree
5 from webhelpers.html.builder import escape
5 from webhelpers.html.builder import escape
6 from vcs.utils.lazy import LazyProperty
6 from vcs.utils.lazy import LazyProperty
@@ -33,7 +33,7 project_path = dn(dn(dn(dn(os.path.realp
33 sys.path.append(project_path)
33 sys.path.append(project_path)
34
34
35 from rhodecode.lib.pidlock import LockHeld, DaemonLock
35 from rhodecode.lib.pidlock import LockHeld, DaemonLock
36 from rhodecode.model.hg_model import HgModel
36 from rhodecode.model.hg import HgModel
37 from rhodecode.lib.helpers import safe_unicode
37 from rhodecode.lib.helpers import safe_unicode
38 from whoosh.index import create_in, open_dir
38 from whoosh.index import create_in, open_dir
39 from shutil import rmtree
39 from shutil import rmtree
@@ -30,10 +30,10 from mercurial.hgweb import hgweb
30 from mercurial.hgweb.request import wsgiapplication
30 from mercurial.hgweb.request import wsgiapplication
31 from paste.auth.basic import AuthBasicAuthenticator
31 from paste.auth.basic import AuthBasicAuthenticator
32 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
32 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
33 from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware, \
33 from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware
34 get_user_cached
35 from rhodecode.lib.utils import is_mercurial, make_ui, invalidate_cache, \
34 from rhodecode.lib.utils import is_mercurial, make_ui, invalidate_cache, \
36 check_repo_fast, ui_sections
35 check_repo_fast, ui_sections
36 from rhodecode.model.user import UserModel
37 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
37 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
38 from rhodecode.lib.utils import action_logger
38 from rhodecode.lib.utils import action_logger
39 import logging
39 import logging
@@ -163,7 +163,7 class SimpleHg(object):
163 return environ.get('REMOTE_USER')
163 return environ.get('REMOTE_USER')
164
164
165 def __get_user(self, username):
165 def __get_user(self, username):
166 return get_user_cached(username)
166 return UserModel().get_by_username(username, cache=True)
167
167
168 def __get_action(self, environ):
168 def __get_action(self, environ):
169 """
169 """
@@ -22,10 +22,12 Created on April 18, 2010
22 Utilities for RhodeCode
22 Utilities for RhodeCode
23 @author: marcink
23 @author: marcink
24 """
24 """
25 from beaker.cache import cache_region
25 from rhodecode.model.caching_query import FromCache
26 from mercurial import ui, config, hg
26 from mercurial import ui, config, hg
27 from mercurial.error import RepoError
27 from mercurial.error import RepoError
28 from rhodecode.model import meta
28 from rhodecode.model import meta
29 from rhodecode.model.user import UserModel
30 from rhodecode.model.repo import RepoModel
29 from rhodecode.model.db import Repository, User, RhodeCodeUi, RhodeCodeSettings, UserLog
31 from rhodecode.model.db import Repository, User, RhodeCodeUi, RhodeCodeSettings, UserLog
30 from vcs.backends.base import BaseChangeset
32 from vcs.backends.base import BaseChangeset
31 from vcs.utils.lazy import LazyProperty
33 from vcs.utils.lazy import LazyProperty
@@ -67,13 +69,13 def action_logger(user, action, repo, ip
67 """
69 """
68
70
69 if not sa:
71 if not sa:
70 sa = meta.Session
72 sa = meta.Session()
71
73
72 try:
74 try:
73 if hasattr(user, 'user_id'):
75 if hasattr(user, 'user_id'):
74 user_id = user.user_id
76 user_id = user.user_id
75 elif isinstance(user, basestring):
77 elif isinstance(user, basestring):
76 user_id = sa.query(User).filter(User.username == user).one()
78 user_id = UserModel(sa).get_by_username(user, cache=False).user_id
77 else:
79 else:
78 raise Exception('You have to provide user object or username')
80 raise Exception('You have to provide user object or username')
79
81
@@ -82,8 +84,7 def action_logger(user, action, repo, ip
82 user_log.user_id = user_id
84 user_log.user_id = user_id
83 user_log.action = action
85 user_log.action = action
84 user_log.repository_name = repo_name
86 user_log.repository_name = repo_name
85 user_log.repository = sa.query(Repository)\
87 user_log.repository = RepoModel(sa).get(repo_name, cache=False)
86 .filter(Repository.repo_name == repo_name).one()
87 user_log.action_date = datetime.datetime.now()
88 user_log.action_date = datetime.datetime.now()
88 user_log.user_ip = ipaddr
89 user_log.user_ip = ipaddr
89 sa.add(user_log)
90 sa.add(user_log)
@@ -135,11 +136,14 def ask_ok(prompt, retries=4, complaint=
135 if retries < 0: raise IOError
136 if retries < 0: raise IOError
136 print complaint
137 print complaint
137
138
138 @cache_region('super_short_term', 'cached_hg_ui')
139 def get_hg_ui_cached():
139 def get_hg_ui_cached():
140 try:
140 try:
141 sa = meta.Session
141 sa = meta.Session
142 ret = sa.query(RhodeCodeUi).all()
142 ret = sa.query(RhodeCodeUi)\
143 .options(FromCache("sql_cache_short", "get_hg_ui_settings"))\
144 .all()
145 except:
146 pass
143 finally:
147 finally:
144 meta.Session.remove()
148 meta.Session.remove()
145 return ret
149 return ret
@@ -147,8 +151,12 def get_hg_ui_cached():
147
151
148 def get_hg_settings():
152 def get_hg_settings():
149 try:
153 try:
150 sa = meta.Session
154 sa = meta.Session()
151 ret = sa.query(RhodeCodeSettings).all()
155 ret = sa.query(RhodeCodeSettings)\
156 .options(FromCache("sql_cache_short", "get_hg_settings"))\
157 .all()
158 except:
159 pass
152 finally:
160 finally:
153 meta.Session.remove()
161 meta.Session.remove()
154
162
@@ -162,8 +170,10 def get_hg_settings():
162
170
163 def get_hg_ui_settings():
171 def get_hg_ui_settings():
164 try:
172 try:
165 sa = meta.Session
173 sa = meta.Session()
166 ret = sa.query(RhodeCodeUi).all()
174 ret = sa.query(RhodeCodeUi).all()
175 except:
176 pass
167 finally:
177 finally:
168 meta.Session.remove()
178 meta.Session.remove()
169
179
@@ -255,11 +265,11 def invalidate_cache(name, *args):
255 args = tuple(tmp)
265 args = tuple(tmp)
256
266
257 if name == 'cached_repo_list':
267 if name == 'cached_repo_list':
258 from rhodecode.model.hg_model import _get_repos_cached
268 from rhodecode.model.hg import _get_repos_cached
259 region_invalidate(_get_repos_cached, None, *args)
269 region_invalidate(_get_repos_cached, None, *args)
260
270
261 if name == 'full_changelog':
271 if name == 'full_changelog':
262 from rhodecode.model.hg_model import _full_changelog_cached
272 from rhodecode.model.hg import _full_changelog_cached
263 region_invalidate(_full_changelog_cached, None, *args)
273 region_invalidate(_full_changelog_cached, None, *args)
264
274
265 class EmptyChangeset(BaseChangeset):
275 class EmptyChangeset(BaseChangeset):
@@ -296,15 +306,14 def repo2db_mapper(initial_repo_list, re
296 """
306 """
297 maps all found repositories into db
307 maps all found repositories into db
298 """
308 """
299 from rhodecode.model.repo_model import RepoModel
300
309
301 sa = meta.Session
310 sa = meta.Session()
302 user = sa.query(User).filter(User.admin == True).first()
311 user = sa.query(User).filter(User.admin == True).first()
303
312
304 rm = RepoModel()
313 rm = RepoModel()
305
314
306 for name, repo in initial_repo_list.items():
315 for name, repo in initial_repo_list.items():
307 if not sa.query(Repository).filter(Repository.repo_name == name).scalar():
316 if not RepoModel(sa).get(name, cache=False):
308 log.info('repository %s not found creating default', name)
317 log.info('repository %s not found creating default', name)
309
318
310 form_data = {
319 form_data = {
@@ -429,7 +438,7 class OrderedDict(dict, DictMixin):
429
438
430
439
431 #===============================================================================
440 #===============================================================================
432 # TEST FUNCTIONS
441 # TEST FUNCTIONS AND CREATORS
433 #===============================================================================
442 #===============================================================================
434 def create_test_index(repo_location, full_index):
443 def create_test_index(repo_location, full_index):
435 """Makes default test index
444 """Makes default test index
@@ -26,18 +26,17 from pylons import session
26 from pylons.i18n.translation import _
26 from pylons.i18n.translation import _
27 from rhodecode.lib.auth import check_password, get_crypt_password
27 from rhodecode.lib.auth import check_password, get_crypt_password
28 from rhodecode.model import meta
28 from rhodecode.model import meta
29 from rhodecode.model.user_model import UserModel
29 from rhodecode.model.user import UserModel
30 from rhodecode.model.db import User, Repository
30 from rhodecode.model.repo import RepoModel
31 from sqlalchemy.exc import OperationalError
31 from rhodecode.model.db import User
32 from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
33 from webhelpers.pylonslib.secure_form import authentication_token
32 from webhelpers.pylonslib.secure_form import authentication_token
34 import formencode
33 import formencode
35 import logging
34 import logging
36 import os
35 import os
37 import rhodecode.lib.helpers as h
36 import rhodecode.lib.helpers as h
37
38 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
39
39
40
41 #this is needed to translate the messages using _() in validators
40 #this is needed to translate the messages using _() in validators
42 class State_obj(object):
41 class State_obj(object):
43 _ = staticmethod(_)
42 _ = staticmethod(_)
@@ -60,17 +59,15 def ValidUsername(edit, old_data):
60 def validate_python(self, value, state):
59 def validate_python(self, value, state):
61 if value in ['default', 'new_user']:
60 if value in ['default', 'new_user']:
62 raise formencode.Invalid(_('Invalid username'), value, state)
61 raise formencode.Invalid(_('Invalid username'), value, state)
63 #check if user is uniq
62 #check if user is unique
64 sa = meta.Session
65 old_un = None
63 old_un = None
66 if edit:
64 if edit:
67 old_un = sa.query(User).get(old_data.get('user_id')).username
65 old_un = UserModel().get(old_data.get('user_id')).username
68
66
69 if old_un != value or not edit:
67 if old_un != value or not edit:
70 if sa.query(User).filter(User.username == value).scalar():
68 if UserModel().get_by_username(value, cache=False):
71 raise formencode.Invalid(_('This username already exists') ,
69 raise formencode.Invalid(_('This username already exists') ,
72 value, state)
70 value, state)
73 meta.Session.remove()
74
71
75 return _ValidUsername
72 return _ValidUsername
76
73
@@ -95,7 +92,7 class ValidAuth(formencode.validators.Fa
95 def validate_python(self, value, state):
92 def validate_python(self, value, state):
96 password = value['password']
93 password = value['password']
97 username = value['username']
94 username = value['username']
98 user = UserModel().get_user_by_name(username)
95 user = UserModel().get_by_username(username)
99 if user is None:
96 if user is None:
100 raise formencode.Invalid(self.message('invalid_password',
97 raise formencode.Invalid(self.message('invalid_password',
101 state=State_obj), value, state,
98 state=State_obj), value, state,
@@ -120,8 +117,9 class ValidAuth(formencode.validators.Fa
120 class ValidRepoUser(formencode.validators.FancyValidator):
117 class ValidRepoUser(formencode.validators.FancyValidator):
121
118
122 def to_python(self, value, state):
119 def to_python(self, value, state):
120 sa = meta.Session()
123 try:
121 try:
124 self.user_db = meta.Session.query(User)\
122 self.user_db = sa.query(User)\
125 .filter(User.active == True)\
123 .filter(User.active == True)\
126 .filter(User.username == value).one()
124 .filter(User.username == value).one()
127 except Exception:
125 except Exception:
@@ -141,11 +139,9 def ValidRepoName(edit, old_data):
141 raise formencode.Invalid(_('This repository name is disallowed'),
139 raise formencode.Invalid(_('This repository name is disallowed'),
142 value, state)
140 value, state)
143 if old_data.get('repo_name') != value or not edit:
141 if old_data.get('repo_name') != value or not edit:
144 sa = meta.Session
142 if RepoModel().get(slug, cache=False):
145 if sa.query(Repository).filter(Repository.repo_name == slug).scalar():
146 raise formencode.Invalid(_('This repository already exists') ,
143 raise formencode.Invalid(_('This repository already exists') ,
147 value, state)
144 value, state)
148 meta.Session.remove()
149 return slug
145 return slug
150
146
151
147
@@ -213,7 +209,7 def UniqSystemEmail(old_data):
213 class _UniqSystemEmail(formencode.validators.FancyValidator):
209 class _UniqSystemEmail(formencode.validators.FancyValidator):
214 def to_python(self, value, state):
210 def to_python(self, value, state):
215 if old_data.get('email') != value:
211 if old_data.get('email') != value:
216 sa = meta.Session
212 sa = meta.Session()
217 try:
213 try:
218 user = sa.query(User).filter(User.email == value).scalar()
214 user = sa.query(User).filter(User.email == value).scalar()
219 if user:
215 if user:
@@ -25,7 +25,6 Model for RhodeCode
25 from beaker.cache import cache_region
25 from beaker.cache import cache_region
26 from mercurial import ui
26 from mercurial import ui
27 from mercurial.hgweb.hgwebdir_mod import findrepos
27 from mercurial.hgweb.hgwebdir_mod import findrepos
28 from pylons.i18n.translation import _
29 from rhodecode.lib import helpers as h
28 from rhodecode.lib import helpers as h
30 from rhodecode.lib.utils import invalidate_cache
29 from rhodecode.lib.utils import invalidate_cache
31 from rhodecode.lib.auth import HasRepoPermissionAny
30 from rhodecode.lib.auth import HasRepoPermissionAny
@@ -23,8 +23,8 Model for permissions
23 @author: marcink
23 @author: marcink
24 """
24 """
25
25
26 from pylons.i18n.translation import _
27 from rhodecode.model.db import User, Permission, UserToPerm, RepoToPerm
26 from rhodecode.model.db import User, Permission, UserToPerm, RepoToPerm
27 from rhodecode.model.caching_query import FromCache
28 from rhodecode.model.meta import Session
28 from rhodecode.model.meta import Session
29 import logging
29 import logging
30 import traceback
30 import traceback
@@ -33,28 +33,35 log = logging.getLogger(__name__)
33
33
34 class PermissionModel(object):
34 class PermissionModel(object):
35
35
36 def __init__(self):
36 def __init__(self, sa=None):
37 if not sa:
37 self.sa = Session()
38 self.sa = Session()
38
39 else:
39 def get_default(self):
40 self.sa = sa
40 return self.sa.query(User).filter(User.username == 'default').scalar()
41
41
42 def get_permission(self, id):
42 def get_permission(self, permission_id, cache=False):
43 return self.sa.query(Permission).get(id)
43 perm = self.sa.query(Permission)
44 if cache:
45 perm = perm.options(FromCache("sql_cache_short",
46 "get_permission_%s" % permission_id))
47 return perm.get(permission_id)
44
48
45 def get_permission_by_name(self, name):
49 def get_permission_by_name(self, name, cache=False):
46 return self.sa.query(Permission)\
50 perm = self.sa.query(Permission)\
47 .filter(Permission.permission_name == name).scalar()
51 .filter(Permission.permission_name == name)
48
52 if cache:
53 perm = perm.options(FromCache("sql_cache_short",
54 "get_permission_%s" % name))
55 return perm.scalar()
49
56
50 def update(self, form_result):
57 def update(self, form_result):
51 perm_user = self.sa.query(User)\
58 perm_user = self.sa.query(User)\
52 .filter(User.username == form_result['perm_user_name']).scalar()
59 .filter(User.username == form_result['perm_user_name']).scalar()
53 u2p = self.sa.query(UserToPerm).filter(UserToPerm.user == perm_user).all()
60 u2p = self.sa.query(UserToPerm).filter(UserToPerm.user == perm_user).all()
54 if len(u2p) != 3:
61 if len(u2p) != 3:
55 raise Exception('There is more than 3 defined \
62 raise Exception('There is more than 3 defined'
56 permissions for defualt user. This should not happen please verify\
63 ' permissions for default user. This should not happen please verify'
57 your database')
64 ' your database')
58
65
59 try:
66 try:
60 #stage 1 change defaults
67 #stage 1 change defaults
@@ -19,15 +19,15
19 """
19 """
20 Created on Jun 5, 2010
20 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
24 from datetime import datetime
25 from datetime import datetime
25 from pylons import app_globals as g
26 from pylons import app_globals as g
26 from rhodecode.lib.utils import check_repo
27 from rhodecode.model.db import Repository, RepoToPerm, User, Permission
27 from rhodecode.model.db import Repository, RepoToPerm, User, Permission
28 from rhodecode.model.meta import Session
28 from rhodecode.model.meta import Session
29 from rhodecode.model.user_model import UserModel
29 from rhodecode.model.user import UserModel
30 from rhodecode.lib.celerylib.tasks import create_repo_fork, run_task
30 from rhodecode.model.caching_query import FromCache
31 import logging
31 import logging
32 import os
32 import os
33 import shutil
33 import shutil
@@ -42,9 +42,14 class RepoModel(object):
42 else:
42 else:
43 self.sa = sa
43 self.sa = sa
44
44
45 def get(self, id):
45 def get(self, repo_id, cache=False):
46 return self.sa.query(Repository)\
46 repo = self.sa.query(Repository)\
47 .filter(Repository.repo_name == id).scalar()
47 .filter(Repository.repo_name == repo_id)
48
49 if cache:
50 repo = repo.options(FromCache("sql_cache_short",
51 "get_repo_%s" % repo))
52 return repo.scalar()
48
53
49 def get_users_js(self):
54 def get_users_js(self):
50
55
@@ -62,8 +67,7 class RepoModel(object):
62 #update permissions
67 #update permissions
63 for username, perm in form_data['perms_updates']:
68 for username, perm in form_data['perms_updates']:
64 r2p = self.sa.query(RepoToPerm)\
69 r2p = self.sa.query(RepoToPerm)\
65 .filter(RepoToPerm.user == self.sa.query(User)\
70 .filter(RepoToPerm.user == UserModel(self.sa).get_by_username(username, cache=False))\
66 .filter(User.username == username).one())\
67 .filter(RepoToPerm.repository == self.get(repo_name))\
71 .filter(RepoToPerm.repository == self.get(repo_name))\
68 .one()
72 .one()
69
73
@@ -76,8 +80,7 class RepoModel(object):
76 for username, perm in form_data['perms_new']:
80 for username, perm in form_data['perms_new']:
77 r2p = RepoToPerm()
81 r2p = RepoToPerm()
78 r2p.repository = self.get(repo_name)
82 r2p.repository = self.get(repo_name)
79 r2p.user = self.sa.query(User)\
83 r2p.user = UserModel(self.sa).get_by_username(username, cache=False)
80 .filter(User.username == username).one()
81
84
82 r2p.permission_id = self.sa.query(Permission).filter(
85 r2p.permission_id = self.sa.query(Permission).filter(
83 Permission.permission_name == perm)\
86 Permission.permission_name == perm)\
@@ -85,7 +88,7 class RepoModel(object):
85 self.sa.add(r2p)
88 self.sa.add(r2p)
86
89
87 #update current repo
90 #update current repo
88 cur_repo = self.get(repo_name)
91 cur_repo = self.get(repo_name, cache=False)
89
92
90 for k, v in form_data.items():
93 for k, v in form_data.items():
91 if k == 'user':
94 if k == 'user':
@@ -130,7 +133,7 class RepoModel(object):
130 #create default permission
133 #create default permission
131 repo_to_perm = RepoToPerm()
134 repo_to_perm = RepoToPerm()
132 default = 'repository.read'
135 default = 'repository.read'
133 for p in UserModel(self.sa).get_default().user_perms:
136 for p in UserModel(self.sa).get_by_username('default', cache=False).user_perms:
134 if p.permission.permission_name.startswith('repository.'):
137 if p.permission.permission_name.startswith('repository.'):
135 default = p.permission.permission_name
138 default = p.permission.permission_name
136 break
139 break
@@ -142,8 +145,7 class RepoModel(object):
142 .one().permission_id
145 .one().permission_id
143
146
144 repo_to_perm.repository_id = new_repo.repo_id
147 repo_to_perm.repository_id = new_repo.repo_id
145 repo_to_perm.user_id = self.sa.query(User)\
148 repo_to_perm.user_id = UserModel(self.sa).get_by_username('default', cache=False).user_id
146 .filter(User.username == 'default').one().user_id
147
149
148 self.sa.add(repo_to_perm)
150 self.sa.add(repo_to_perm)
149 self.sa.commit()
151 self.sa.commit()
@@ -155,7 +157,8 class RepoModel(object):
155 raise
157 raise
156
158
157 def create_fork(self, form_data, cur_user):
159 def create_fork(self, form_data, cur_user):
158 run_task(create_repo_fork, form_data, cur_user)
160 from rhodecode.lib.celerylib import tasks, run_task
161 run_task(tasks.create_repo_fork, form_data, cur_user)
159
162
160 def delete(self, repo):
163 def delete(self, repo):
161 try:
164 try:
@@ -179,6 +182,7 class RepoModel(object):
179 raise
182 raise
180
183
181 def __create_repo(self, repo_name):
184 def __create_repo(self, repo_name):
185 from rhodecode.lib.utils import check_repo
182 repo_path = os.path.join(g.base_path, repo_name)
186 repo_path = os.path.join(g.base_path, repo_name)
183 if check_repo(repo_name, g.base_path):
187 if check_repo(repo_name, g.base_path):
184 log.info('creating repo %s in %s', repo_name, repo_path)
188 log.info('creating repo %s in %s', repo_name, repo_path)
@@ -17,19 +17,19
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
19 # MA 02110-1301, USA.
20
21 """
20 """
22 Created on April 9, 2010
21 Created on April 9, 2010
23 Model for users
22 Model for users
24 @author: marcink
23 :author: marcink
25 """
24 """
26 from rhodecode.lib import auth
25
27 from pylons.i18n.translation import _
26 from pylons.i18n.translation import _
28 from rhodecode.lib.celerylib import tasks, run_task
27 from rhodecode.model.caching_query import FromCache
29 from rhodecode.model.db import User
28 from rhodecode.model.db import User
30 from rhodecode.model.meta import Session
29 from rhodecode.model.meta import Session
30 import logging
31 import traceback
31 import traceback
32 import logging
32
33 log = logging.getLogger(__name__)
33 log = logging.getLogger(__name__)
34
34
35 class DefaultUserException(Exception):pass
35 class DefaultUserException(Exception):pass
@@ -42,14 +42,21 class UserModel(object):
42 else:
42 else:
43 self.sa = sa
43 self.sa = sa
44
44
45 def get_default(self):
45 def get(self, user_id, cache=False):
46 return self.sa.query(User).filter(User.username == 'default').scalar()
46 user = self.sa.query(User)
47 if cache:
48 user = user.options(FromCache("sql_cache_short",
49 "get_user_%s" % user_id))
50 return user.get(user_id)
51
47
52
48 def get_user(self, id):
53 def get_by_username(self, username, cache=False):
49 return self.sa.query(User).get(id)
54 user = self.sa.query(User)\
50
55 .filter(User.username == username)
51 def get_user_by_name(self, name):
56 if cache:
52 return self.sa.query(User).filter(User.username == name).scalar()
57 user = user.options(FromCache("sql_cache_short",
58 "get_user_%s" % username))
59 return user.scalar()
53
60
54 def create(self, form_data):
61 def create(self, form_data):
55 try:
62 try:
@@ -78,9 +85,9 class UserModel(object):
78 self.sa.rollback()
85 self.sa.rollback()
79 raise
86 raise
80
87
81 def update(self, uid, form_data):
88 def update(self, user_id, form_data):
82 try:
89 try:
83 new_user = self.sa.query(User).get(uid)
90 new_user = self.get(user_id, cache=False)
84 if new_user.username == 'default':
91 if new_user.username == 'default':
85 raise DefaultUserException(
92 raise DefaultUserException(
86 _("You can't Edit this user since it's"
93 _("You can't Edit this user since it's"
@@ -98,9 +105,9 class UserModel(object):
98 self.sa.rollback()
105 self.sa.rollback()
99 raise
106 raise
100
107
101 def update_my_account(self, uid, form_data):
108 def update_my_account(self, user_id, form_data):
102 try:
109 try:
103 new_user = self.sa.query(User).get(uid)
110 new_user = self.get(user_id, cache=False)
104 if new_user.username == 'default':
111 if new_user.username == 'default':
105 raise DefaultUserException(
112 raise DefaultUserException(
106 _("You can't Edit this user since it's"
113 _("You can't Edit this user since it's"
@@ -119,10 +126,9 class UserModel(object):
119 self.sa.rollback()
126 self.sa.rollback()
120 raise
127 raise
121
128
122 def delete(self, id):
129 def delete(self, user_id):
123 try:
130 try:
124
131 user = self.get(user_id, cache=False)
125 user = self.sa.query(User).get(id)
126 if user.username == 'default':
132 if user.username == 'default':
127 raise DefaultUserException(
133 raise DefaultUserException(
128 _("You can't remove this user since it's"
134 _("You can't remove this user since it's"
@@ -135,4 +141,5 class UserModel(object):
135 raise
141 raise
136
142
137 def reset_password(self, data):
143 def reset_password(self, data):
144 from rhodecode.lib.celerylib import tasks, run_task
138 run_task(tasks.reset_user_password, data['email'])
145 run_task(tasks.reset_user_password, data['email'])
@@ -2301,6 +2301,8 padding-left:5px;
2301
2301
2302 #changeset_content .container .left .date,.ac .match {
2302 #changeset_content .container .left .date,.ac .match {
2303 font-weight:700;
2303 font-weight:700;
2304 padding-top: 5px;
2305 padding-bottom:5px;
2304 }
2306 }
2305
2307
2306 div#legend_container table td,div#legend_choices table td {
2308 div#legend_container table td,div#legend_choices table td {
@@ -49,19 +49,32 cache_dir = %(here)s/data
49 ####################################
49 ####################################
50 beaker.cache.data_dir=/%(here)s/data/cache/data
50 beaker.cache.data_dir=/%(here)s/data/cache/data
51 beaker.cache.lock_dir=/%(here)s/data/cache/lock
51 beaker.cache.lock_dir=/%(here)s/data/cache/lock
52 beaker.cache.regions=super_short_term,short_term,long_term
52 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
53
54 beaker.cache.super_short_term.type=memory
55 beaker.cache.super_short_term.expire=10
56
57 beaker.cache.short_term.type=memory
58 beaker.cache.short_term.expire=60
59
53 beaker.cache.long_term.type=memory
60 beaker.cache.long_term.type=memory
54 beaker.cache.long_term.expire=36000
61 beaker.cache.long_term.expire=36000
55 beaker.cache.short_term.type=memory
62
56 beaker.cache.short_term.expire=60
63
57 beaker.cache.super_short_term.type=memory
64 beaker.cache.sql_cache_short.type=memory
58 beaker.cache.super_short_term.expire=10
65 beaker.cache.sql_cache_short.expire=5
66
67 beaker.cache.sql_cache_med.type=memory
68 beaker.cache.sql_cache_med.expire=360
69
70 beaker.cache.sql_cache_long.type=file
71 beaker.cache.sql_cache_long.expire=3600
59
72
60 ####################################
73 ####################################
61 ### BEAKER SESSION ####
74 ### BEAKER SESSION ####
62 ####################################
75 ####################################
63 ## Type of storage used for the session, current types are
76 ## Type of storage used for the session, current types are
64 ## "dbm", "file", "memcached", "database", and "memory".
77 ## dbm, file, memcached, database, and memory.
65 ## The storage uses the Container API
78 ## The storage uses the Container API
66 ##that is also used by the cache system.
79 ##that is also used by the cache system.
67 beaker.session.type = file
80 beaker.session.type = file
General Comments 0
You need to be logged in to leave comments. Login now