Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from json import load, JSONDecoder
- from tg import config
- import os
- def parsetagstomap (jsondata, tags = dict()):
- for tag in jsondata:
- if 'data' in tag:
- tags[tag['attributes']['id']] = tag['data']
- tags[tag['data']] = tag['attributes']['id']
- if 'children' in tag:
- tags = parsetagstomap (tag['children'], tags)
- return tags
- def gettagmap ():
- with open('wiki20/public/tags.json', 'r') as f:
- entry = load(f)
- return parsetagstomap(entry)
- app_globals.py
- # -*- coding: utf-8 -*-
- from wiki20.utils.jsonutil import gettagmap
- """The application's Globals object"""
- __all__ = ['Globals']
- class Globals(object):
- """Container for objects available throughout the life of the application.
- One instance of Globals is created during application initialization and
- is available during requests via the 'app_globals' variable.
- """
- def __init__(self):
- """Do nothing, by default."""
- self.tagmap = gettagmap ()
Add Comment
Please, Sign In to add comment