meta.py
27 lines
| 768 B
| text/x-python
|
PythonLexer
r547 | """SQLAlchemy Metadata and Session object""" | |||
from sqlalchemy.ext.declarative import declarative_base | ||||
r1388 | from sqlalchemy.orm import scoped_session, sessionmaker | |||
r1065 | from beaker import cache | |||
r1669 | from rhodecode.lib import caching_query | |||
r1065 | ||||
r547 | ||||
# Beaker CacheManager. A home base for cache configurations. | ||||
cache_manager = cache.CacheManager() | ||||
__all__ = ['Base', 'Session'] | ||||
# | ||||
# SQLAlchemy session manager. Updated by model.init_model() | ||||
# | ||||
Session = scoped_session( | ||||
sessionmaker( | ||||
r1712 | query_cls = caching_query.query_callable(cache_manager), | |||
expire_on_commit = True, | ||||
r547 | ) | |||
) | ||||
# The declarative Base | ||||
r1388 | Base = declarative_base() | |||
r547 | ||||
#to use cache use this in query | ||||
#.options(FromCache("sqlalchemy_cache_type", "cachekey")) | ||||