def get_propertie(name): val = memcache.get(name) if val: return val model = PropertieModel().all() model.filter("name", name) if model.count(1) == 1: res = model.get().value_ru memcache.add(key=name, value=res, time=CMS_CFG["cache_time"]) return res 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()
def _prepare_glob_dict(): email_list = EmailModel().all() email_list.order("-date") product_list = ProductModel().all() product_list.order("-date") images_list = ImageModel().all() images_list.order("-date") propertie_list = PropertieModel().all() propertie_list.order("-date") comment_list = CommentModel().all() comment_list.filter("category", COMMENT_CATEGORY_PAGE) comment_list.order("-date") twitter_list = CommentModel().all() twitter_list.filter("category", COMMENT_CATEGORY_TWITTER) twitter_list.order("-date") glob_dict = { 'langs':CMS_LANGUAGES, 'page_list':get_pages(), 'blog_list':get_blog_pages(), 'menu_list':get_menus(), 'email_list':email_list, 'product_list':product_list, 'comment_list':comment_list, 'twitter_list':twitter_list, 'image_list':images_list, 'propertie_list':propertie_list, "admin_menu" : admin_menu } return glob_dict