Ejemplo n.º 1
0
def get_exercise(ex_id):
    key = '%s%s' % (KEY_EXERCISE, ex_id)
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.Exercises.query.filter_by(id=ex_id).first()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 2
0
def get_page_content(page_title):
    key = '%s%s' % (KEY_PAGE, page_title)
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.PageContent.query.filter_by(page=page_title).first().get_content()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 3
0
def get_exercise_list():
    key = KEY_EXERCISES
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.Exercises.query.all()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 4
0
def get_pages():
    key = KEY_PAGES
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.PageContent.query.all()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 5
0
def get_exercise(ex_id):
    key = '%s%s' % (KEY_EXERCISE, ex_id)
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.Exercises.query.filter_by(id=ex_id).first()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 6
0
def get_exercise_list():
    key = KEY_EXERCISES
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.Exercises.query.all()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 7
0
def get_pages():
    key = KEY_PAGES
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.PageContent.query.all()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val
Ejemplo n.º 8
0
def get_page(pg_id):
    key = '%s%s' % (KEY_PAGE, pg_id)
    val = cache.get(key)
    if val is None:
        print 'cache miss'
        val = models.PageContent.query.filter_by(id=pg_id).first()
        if val is None:
            val = ERROR_DB_MSG
        cache.set(key, val, timeout=TIMEOUT)
    return val