annotate rhodecode/model/meta.py @ 3972:3cb5a35a319d

added migrations for column change for gists expiration date
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 11 Jun 2013 14:22:54 +0200
parents 6c86c987cf93
children ffd45b185016
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
1388
2029c17cc6c6 Added basic JsonSerialization into models.
Marcin Kuzminski <marcin@python-works.com>
parents: 1271
diff changeset
3 from sqlalchemy.orm import scoped_session, sessionmaker
1065
5d676b6ab71c Moved BaseModel into base class for declarative base. Added some handy methods into
Marcin Kuzminski <marcin@python-works.com>
parents: 612
diff changeset
4 from beaker import cache
5d676b6ab71c Moved BaseModel into base class for declarative base. Added some handy methods into
Marcin Kuzminski <marcin@python-works.com>
parents: 612
diff changeset
5
1669
f522f4d3bf93 moved caching query to libs
Marcin Kuzminski <marcin@python-works.com>
parents: 1388
diff changeset
6 from rhodecode.lib import caching_query
1065
5d676b6ab71c Moved BaseModel into base class for declarative base. Added some handy methods into
Marcin Kuzminski <marcin@python-works.com>
parents: 612
diff changeset
7
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
8
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
9 # 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
10 cache_manager = cache.CacheManager()
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
11
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
12 __all__ = ['Base', 'Session']
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13 #
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14 # SQLAlchemy session manager. Updated by model.init_model()
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
15 #
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
16 Session = scoped_session(
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
17 sessionmaker(
1800
6c86c987cf93 pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
18 query_cls=caching_query.query_callable(cache_manager),
6c86c987cf93 pep8ify
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
19 expire_on_commit=True,
482
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
1388
2029c17cc6c6 Added basic JsonSerialization into models.
Marcin Kuzminski <marcin@python-works.com>
parents: 1271
diff changeset
24 Base = declarative_base()
482
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
25
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
26 #to use cache use this in query
7afbc45aab28 added caching queries to hg-app
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
27 #.options(FromCache("sqlalchemy_cache_type", "cachekey"))