diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-21 16:54:42 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-21 16:54:42 -0400 |
| commit | 39d17c76df542d0040c2c8db2d2e3dc897b5cce5 (patch) | |
| tree | f5aeba8be0f61c0db8d5ba0e76efdaa593cd85c4 /examples/beaker_caching/environment.py | |
| parent | f2bc0ddcb496e6a0cb0a0ad88c7c055dbf0c11a7 (diff) | |
| download | sqlalchemy-39d17c76df542d0040c2c8db2d2e3dc897b5cce5.tar.gz | |
- converted beaker demo to dogpile.cache, [ticket:2589]
Diffstat (limited to 'examples/beaker_caching/environment.py')
| -rw-r--r-- | examples/beaker_caching/environment.py | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/examples/beaker_caching/environment.py b/examples/beaker_caching/environment.py deleted file mode 100644 index ccc625117..000000000 --- a/examples/beaker_caching/environment.py +++ /dev/null @@ -1,67 +0,0 @@ -"""environment.py - -Establish data / cache file paths, and configurations, -bootstrap fixture data if necessary. - -""" -import caching_query -from sqlalchemy import create_engine -from sqlalchemy.orm import scoped_session, sessionmaker -from sqlalchemy.ext.declarative import declarative_base -from beaker import cache -import os - -# Beaker CacheManager. A home base for cache configurations. -cache_manager = cache.CacheManager() - -# scoped_session. Apply our custom CachingQuery class to it, -# using a callable that will associate the cache_manager -# with the Query. -Session = scoped_session( - sessionmaker( - query_cls=caching_query.query_callable(cache_manager) - ) - ) - -# global declarative base class. -Base = declarative_base() - - -root = "./beaker_data/" - -if not os.path.exists(root): - raw_input("Will create datafiles in %r.\n" - "To reset the cache + database, delete this directory.\n" - "Press enter to continue.\n" % root - ) - os.makedirs(root) - -dbfile = os.path.join(root, "beaker_demo.db") -engine = create_engine('sqlite:///%s' % dbfile, echo=True) -Session.configure(bind=engine) - -# configure the "default" cache region. -cache_manager.regions['default'] ={ - - # using type 'file' to illustrate - # serialized persistence. In reality, - # use memcached. Other backends - # are much, much slower. - 'type':'file', - 'data_dir':root, - 'expire':3600, - - # set start_time to current time - # to re-cache everything - # upon application startup - #'start_time':time.time() - } - -installed = False - -def bootstrap(): - global installed - import fixture_data - if not os.path.exists(dbfile): - fixture_data.install() - installed = True
\ No newline at end of file |
