def get_properties(name): val = memcache.get(name) if val: return val model = PropertieModel().all() model.filter("name", name) if model.count(1) == 1: memcache.add(key=name, value=model.get(), time=CMS_CFG["cache_time"]) return model.get() else: memcache.add(key=name, value="", time=CMS_CFG["cache_time"]) return ""
def get_propertie(name_key, lang=LANG_CODE_DEFAULT): if lang not in CMS_LANGUAGES.keys(): lang = LANG_CODE_DEFAULT result = "[%s.%s]" % (name_key, lang) if lang in CMS_LANGUAGES.keys(): properties = PropertieModel().all() properties.filter("name", name_key) if properties.count() > 0: result = getattr(properties[0], "value_" + lang) return result
def populate_properties(): if DEBUG: all = PropertieModel().all() for item in all: item.delete() for propertie in default_properties: model = PropertieModel().all() model.filter("name", propertie["name"]) if model.count() == 0: new = PropertieModel() new.name = propertie["name"] new.value_ru = propertie["value_ru"] new.value_en = propertie["value_en"] new.put()