コード例 #1
0
ファイル: dolly.py プロジェクト: philpill/romeo
def get_categories():
    cachekey = "dolly_categories"
    categories = cache.get(cachekey)
    if not categories:
        sortorder = dict(key=lambda c: c["priority"], reverse=True)
        response = _request("categories/")
        categories = response.json()["categories"]["items"]
        categories.sort(**sortorder)
        for cat in categories:
            cat["sub_categories"].sort(**sortorder)
        # XXX: Exclude the first top-level category (Editors Picks)
        categories = categories[1:]
        if response.cache_max_age:
            cache.set(cachekey, categories, response.cache_max_age)
    return categories
コード例 #2
0
ファイル: fixtures.py プロジェクト: philpill/romeo
def loaddata():
    datasets = [d for d in globals().values() if type(d) is type(DataSet) and d is not DataSet]

    dbfixture.data(*datasets).setup()

    cache.set('dolly_categories', [dict(id=1, name='Food', sub_categories=[])])