Changeset - 79457e03ef68
[Not reviewed]
Merge default
0 7 0
Marcin Kuzminski - 15 years ago 2010-10-18 15:29:56
marcin@python-works.com
6 files changed with 29 insertions and 13 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -60,6 +60,7 @@ beaker.cache.short_term.expire=60
 
beaker.cache.long_term.type=memory
 
beaker.cache.long_term.expire=36000
 

	
 

	
 
beaker.cache.sql_cache_short.type=memory
 
beaker.cache.sql_cache_short.expire=5
 

	
production.ini
Show inline comments
 
@@ -60,6 +60,7 @@ beaker.cache.short_term.expire=60
 
beaker.cache.long_term.type=memory
 
beaker.cache.long_term.expire=36000
 

	
 

	
 
beaker.cache.sql_cache_short.type=memory
 
beaker.cache.sql_cache_short.expire=5
 

	
 
@@ -73,7 +74,7 @@ beaker.cache.sql_cache_long.expire=3600
 
###       BEAKER SESSION        ####
 
####################################
 
## Type of storage used for the session, current types are 
 
## "dbm", "file", "memcached", "database", and "memory".
 
## dbm, file, memcached, database, and memory. 
 
## The storage uses the Container API 
 
##that is also used by the cache system.
 
beaker.session.type = file
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -74,7 +74,7 @@ beaker.cache.sql_cache_long.expire=3600
 
###       BEAKER SESSION        ####
 
####################################
 
## Type of storage used for the session, current types are 
 
## "dbm", "file", "memcached", "database", and "memory".
 
## dbm, file, memcached, database, and memory. 
 
## The storage uses the Container API 
 
##that is also used by the cache system.
 
beaker.session.type = file
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -23,6 +23,11 @@ changelog controller for pylons
 
@author: marcink
 
"""
 

	
 
try:
 
    import json
 
except ImportError:
 
    #python 2.5 compatibility
 
    import simplejson as json
 
from mercurial.graphmod import colored, CHANGESET, revisions as graph_rev
 
from pylons import request, session, tmpl_context as c
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
@@ -32,12 +37,6 @@ from webhelpers.paginate import Page
 
import logging
 
log = logging.getLogger(__name__)
 

	
 
try:
 
    import json
 
except ImportError:
 
    #python 2.5 compatibility
 
    import simplejson as json
 

	
 
class ChangelogController(BaseController):
 
    
 
    @LoginRequired()
rhodecode/lib/auth.py
Show inline comments
 
@@ -27,6 +27,7 @@ from pylons import config, session, url,
 
from pylons.controllers.util import abort, redirect
 
from rhodecode.lib.utils import get_repo_slug
 
from rhodecode.model import meta
 
from rhodecode.model.caching_query import FromCache
 
from rhodecode.model.db import User, RepoToPerm, Repository, Permission, \
 
    UserToPerm
 
from sqlalchemy.exc import OperationalError
 
@@ -141,7 +142,9 @@ def fill_data(user):
 
    :param user:
 
    """
 
    sa = meta.Session
 
    dbuser = sa.query(User).get(user.user_id)
 
    dbuser = sa.query(User).options(FromCache('sql_cache_short',
 
                                              'getuser_%s' % user.user_id))\
 
        .get(user.user_id)
 
    if dbuser:
 
        user.username = dbuser.username
 
        user.is_admin = dbuser.admin
 
@@ -166,11 +169,14 @@ def fill_perms(user):
 
    #===========================================================================
 
    # fetch default permissions
 
    #===========================================================================
 
    default_user = sa.query(User)\
 
        .options(FromCache('sql_cache_short','getuser_%s' % 'default'))\
 
        .filter(User.username == 'default').scalar()
 
                                            
 
    default_perms = sa.query(RepoToPerm, Repository, Permission)\
 
        .join((Repository, RepoToPerm.repository_id == Repository.repo_id))\
 
        .join((Permission, RepoToPerm.permission_id == Permission.permission_id))\
 
        .filter(RepoToPerm.user == sa.query(User).filter(User.username == 
 
                                            'default').scalar()).all()
 
        .filter(RepoToPerm.user == default_user).all()
 
                                            
 
    if user.is_admin:
 
        #=======================================================================
rhodecode/model/caching_query.py
Show inline comments
 
@@ -18,9 +18,11 @@ The rest of what's here are standard SQL
 
Beaker constructs.
 
   
 
"""
 
from beaker.exceptions import BeakerException
 
from sqlalchemy.orm.interfaces import MapperOption
 
from sqlalchemy.orm.query import Query
 
from sqlalchemy.sql import visitors
 
import beaker
 

	
 
class CachingQuery(Query):
 
    """A Query subclass which optionally loads full results from a Beaker 
 
@@ -106,6 +108,13 @@ def query_callable(manager):
 
        return CachingQuery(manager, *arg, **kw)
 
    return query
 
    
 
def get_cache_region(name, region):
 
    if region not in beaker.cache.cache_regions:
 
        raise BeakerException('Cache region not configured: %s'
 
            'Check if proper cache settings are in the .ini files' % region)
 
    kw = beaker.cache.cache_regions[region]
 
    return beaker.cache.Cache._get_cache(name, kw)
 
    
 
def _get_cache_parameters(query):
 
    """For a query with cache_region and cache_namespace configured,
 
    return the correspoinding Cache instance and cache key, based
 
@@ -125,8 +134,8 @@ def _get_cache_parameters(query):
 
        cache_key = " ".join([str(x) for x in args])
 

	
 
    # get cache
 
    cache = query.cache_manager.get_cache_region(namespace, region)
 

	
 
    #cache = query.cache_manager.get_cache_region(namespace, region)
 
    cache = get_cache_region(namespace, region)
 
    # optional - hash the cache_key too for consistent length
 
    # import uuid
 
    # cache_key= str(uuid.uuid5(uuid.NAMESPACE_DNS, cache_key))
0 comments (0 inline, 0 general)