# Path: gengine/metadata.py
# class MySession(Session):
#     """This allow us to use the flask-admin sqla extension, which uses DBSession.commit() rather than transaction.commit()"""
#     def commit(self,*args,**kw):
#         transaction.commit(*args,**kw)
# 
#     def rollback(self, *args, **kw):
#         transaction.abort(*args,**kw)
# 
# Path: gengine/app/cache.py
# def init_caches():
#     global cache_general
#     cache_general = create_cache("general")
# 
#     global cache_achievement_eval
#     cache_achievement_eval = create_cache("achievement_eval")
# 
#     global cache_achievements_by_subject_for_today
#     cache_achievements_by_subject_for_today = create_cache("achievements_by_subject_for_today")
# 
#     global cache_achievements_subjects_levels
#     cache_achievements_subjects_levels = create_cache("achievements_subjects_levels")
# 
#     global cache_translations
#     cache_translations = create_cache("translations")
# 
#     # The Goal evaluation Cache is implemented as a two-level cache (persistent in db, non-persistent as dogpile)
#     global cache_goal_evaluation
#     cache_goal_evaluation = create_cache("goal_evaluation")
# 
#     #global cache_goal_statements
#     #cache_goal_statements = create_memory_cache("goal_statements")


import sys
import logging
import os
import pyramid_dogpile_cache
import transaction
    import gengine.app.model as m
from zope.sqlalchemy.datamanager import mark_changed
from gengine.metadata import MySession
from gengine.app.cache import init_caches
from pyramid.config import Configurator
from pyramid.paster import (
    get_appsettings,
    setup_logging,
)
from pyramid.scripts.common import parse_vars
from sqlalchemy import engine_from_config
    from gengine.base.settings import set_settings
    from gengine.metadata import (
        init_session,
        init_declarative_base,
        init_db
    )
    from gengine.metadata import (
        DBSession
    )
          '(example: "%s production.ini")' % (cmd, cmd))
    sys.exit(1)


def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)

    set_settings(settings)

    durl = os.environ.get("DATABASE_URL")  # heroku
    if durl:
        settings['sqlalchemy.url'] = durl

    murl = os.environ.get("MEMCACHED_URL")
    if murl:
        settings['urlcache_url'] = murl

    engine = engine_from_config(settings, 'sqlalchemy.')

    config = Configurator(settings=settings)
    pyramid_dogpile_cache.includeme(config)

    init_session()
    init_declarative_base()
    init_db(engine)

# Path: gengine/metadata.py
# class MySession(Session):
#     """This allow us to use the flask-admin sqla extension, which uses DBSession.commit() rather than transaction.commit()"""
#     def commit(self,*args,**kw):
#         transaction.commit(*args,**kw)
# 
#     def rollback(self, *args, **kw):
#         transaction.abort(*args,**kw)
# 
# Path: gengine/app/cache.py
# def init_caches():
#     global cache_general
#     cache_general = create_cache("general")
# 
#     global cache_achievement_eval
#     cache_achievement_eval = create_cache("achievement_eval")
# 
#     global cache_achievements_by_subject_for_today
#     cache_achievements_by_subject_for_today = create_cache("achievements_by_subject_for_today")
# 
#     global cache_achievements_subjects_levels
#     cache_achievements_subjects_levels = create_cache("achievements_subjects_levels")
# 
#     global cache_translations
#     cache_translations = create_cache("translations")
# 
#     # The Goal evaluation Cache is implemented as a two-level cache (persistent in db, non-persistent as dogpile)
#     global cache_goal_evaluation
#     cache_goal_evaluation = create_cache("goal_evaluation")
# 
#     #global cache_goal_statements
#     #cache_goal_statements = create_memory_cache("goal_statements")


# Path: gengine/maintenance/scripts/push_messages.py
import sys
import logging
import os
import pyramid_dogpile_cache
import transaction
    import gengine.app.model as m
from zope.sqlalchemy.datamanager import mark_changed
from gengine.metadata import MySession
from gengine.app.cache import init_caches
from pyramid.config import Configurator
from pyramid.paster import (
    get_appsettings,
    setup_logging,
)
from pyramid.scripts.common import parse_vars
from sqlalchemy import engine_from_config
    from gengine.base.settings import set_settings
    from gengine.metadata import (
        init_session,
        init_declarative_base,
        init_db
    )
    from gengine.metadata import (
        DBSession
    )

          '(example: "%s production.ini")' % (cmd, cmd))
    sys.exit(1)


def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)

    set_settings(settings)

    durl = os.environ.get("DATABASE_URL")  # heroku
    if durl:
        settings['sqlalchemy.url'] = durl

    murl = os.environ.get("MEMCACHED_URL")
    if murl:
        settings['urlcache_url'] = murl

    engine = engine_from_config(settings, 'sqlalchemy.')

    config = Configurator(settings=settings)
    pyramid_dogpile_cache.includeme(config)

    init_session()
    init_declarative_base()
    init_db(engine)

    init_caches()