annotate rhodecode/model/meta.py @ 609:c1c1cf772337

moved out sqlalchemy cache from meta to the config files. added caching query for permissions.
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 12 Oct 2010 16:39:53 +0200
parents 342f8434ed14
children 79457e03ef68
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """SQLAlchemy Metadata and Session object"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2 from sqlalchemy.ext.declarative import declarative_base
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
3 from sqlalchemy.orm import scoped_session, sessionmaker
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 482
diff changeset
4 from rhodecode.model import caching_query
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
5 from beaker import cache
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
6 import os
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
7 from os.path import join as jn, dirname as dn, abspath
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
8 import time
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
9
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
10 # Beaker CacheManager. A home base for cache configurations.
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
11 cache_manager = cache.CacheManager()
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
12
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13 __all__ = ['Base', 'Session']
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14 #
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
15 # SQLAlchemy session manager. Updated by model.init_model()
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
16 #
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
17 Session = scoped_session(
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
18 sessionmaker(
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
19 query_cls=caching_query.query_callable(cache_manager)
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
20 )
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
21 )
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
22
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 # The declarative Base
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
24 Base = declarative_base()
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
25 #For another db...
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
26 #Base2 = declarative_base()
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
27
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
28 #===============================================================================
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
29 # CACHE OPTIONS
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
30 #===============================================================================
609
c1c1cf772337 moved out sqlalchemy cache from meta to the config files.
Marcin Kuzminski <marcin@python-works.com>
parents: 550
diff changeset
31 #Configured globally in .ini files
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
32 #to use cache use this in query
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
33 #.options(FromCache("sqlalchemy_cache_type", "cachekey"))