def get(self): languages = Languages.all() logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url('/langs' ) else: login = users.create_login_url('/langs/create') self.render_template('LangList.html', {'languages': languages,'currentuser':currentuser, 'login':login, 'logout': logout})
def get(self): # langCode='en' langCode = self.request.get("langCode") languages = Languages.all().filter("langCode =", langCode) langName = "no language" for language in languages: if language.langCode == langCode: langName = language.langName # if not langName: # langName = 'no language' # templateName='khan-exercise' templateName = self.request.get("templateName") q = db.GqlQuery( "SELECT * FROM TokenValues " + "WHERE langCode = :1 AND templateName = :2 " + "ORDER BY tknID ASC", langCode, templateName, ) tokens = q.fetch(999) # tokens = TokenValues.all() # tokens = TokenValues.query() # langCode='en' # if self.request.get('langCode'): # langCode=self.request.get('langCode') # tokens = TokenValues.query(TokenValues.langCode == langCode) # tokens = tokens.filter('langCode =', langCode) logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url("/tokens") else: login = users.create_login_url("/tokens/create") self.render_template( "TokenList.html", { "tokens": tokens, "langName": langName, "templateName": templateName, "currentuser": currentuser, "login": login, "logout": logout, }, )
def get(self): languages = memcache.get("languages") if languages is not None: logging.info("get languages from memcache.") else: languages = Languages.all() logging.info("Can not get languages from memcache.") if not memcache.add("languages", languages, 10): logging.info("Memcache set failed.") if self.request.get('langCode'): langCode=self.request.get('langCode') self.session['langCode'] = langCode else: langCode = self.session.get('langCode') if not langCode: self.session['langCode'] = 'en' LangName = 'no language' for language in languages: if language.langCode == langCode: langName = language.langName # q = db.GqlQuery("SELECT * FROM PageContents " + # "WHERE langCode = :1 " + # "ORDER BY TemplateName ASC", # "en") # pagecontents = q.fetch(999) pagecontents = PageContents.all() logging.info('QQQ: PageContents.all(): %s' % PageContents.all()) #logging.info('QQQ: pagecontents: %s' % pagecontents) if not pagecontents: pagecontents = 'xxx' logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url('/pagecontents' ) else: login = users.create_login_url('/pagecontents/create') # self.render_template('PageContentList.html', {'pagecontents': pagecontents, 'LangName':LangName, 'currentuser':currentuser, 'login':login, 'logout': logout}) self.render_template('PageContentList.html', {'pagecontents': pagecontents, 'currentuser':currentuser, 'login':login, 'logout': logout})
def get(self): # languages = Languages.all() languages = memcache.get("languages") if languages is not None: logging.info("get languages from memcache.") else: languages = Languages.all() logging.info("Can not get languages from memcache.") if not memcache.add("languages", languages, 10): logging.info("Memcache set failed.") if self.request.get("langCode"): langCode = self.request.get("langCode") self.session["langCode"] = langCode else: langCode = self.session.get("langCode") if not langCode: self.session["langCode"] = "en" # currLanguage = languages.filter('langCode =', langCode) langName = "no language" for language in languages: if language.langCode == langCode: langName = language.langName # if not langName: # langName = 'no language' PageCnt = self.session.get("PageCnt", 0) # PageCnt = int(0 if PageCnt is None else PageCnt) + 1 self.session["PageCnt"] = PageCnt + 1 countmap_en = {} tokens = TokenValues.all().filter("langCode =", langCode) for token in tokens: logging.info("QQQ: token: %s" % token.langCode) if token.templateName in countmap_en: countmap_en[token.templateName] = countmap_en[token.templateName] + 1 else: countmap_en[token.templateName] = 1 countmap_other_language = {} if langCode != "en": tokens = TokenValues().all().filter("langCode =", langCode) for token in tokens: logging.info("QQQ: token: %s" % token.langCode) if token.templateName in countmap_other_language: countmap_other_language[token.templateName] = countmap_other_language[token.templateName] + 1 else: countmap_other_language[token.templateName] = 1 logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url("/tokens") else: login = users.create_login_url("/tokens/create") self.render_template( "TokenStep1.html", { "PageCnt": PageCnt, "languages": languages, "langCode": langCode, "langName": langName, "countmap_en": countmap_en, "countmap_other_language": countmap_other_language, "tokens": tokens, "currentuser": currentuser, "login": login, "logout": logout, }, )
def get(self): languages = Languages.all() countmap_other_language = {} # templateName2 = 'khan-exercise' and 'templateName', templateName2 langCode2 = "" if self.request.get("langCode"): langCode2 = self.request.get("langCode") if langCode2 == "en": langCode2 = "xx" if self.request.get("templateName"): templateName2 = self.request.get("templateName") if langCode2 != "en": q = db.GqlQuery( "SELECT * FROM TokenValues " + "WHERE langCode = :1 AND templateName = :2 " + "ORDER BY tknID ASC", langCode2, templateName2, ) tokens = q.fetch(999) # tokens = TokenValues().all().filter('langCode =', langCode2) for token in tokens: logging.info("QQQ: token: %s" % token.langCode) if token.tknID not in countmap_other_language: countmap_other_language[token.tknID] = 1 langCode = "en" q = db.GqlQuery( "SELECT * FROM TokenValues " + "WHERE langCode = :1 AND templateName = :2 " + "ORDER BY tknID ASC", langCode, templateName2, ) tokens = q.fetch(999) # tokens = TokenValues.all().filter('langCode =', langCode) logout = None login = None currentuser = users.get_current_user() if currentuser: logout = users.create_logout_url("/tokens") else: login = users.create_login_url("/tokens/create") if langCode2 == "xx": self.render_template( "TokenStep1.html", { "languages": languages, "langCode": langCode, "countmap_other_language": countmap_other_language, "tokens": tokens, "currentuser": currentuser, "login": login, "logout": logout, }, ) else: for token in tokens: if token.tknID not in countmap_other_language: n = TokenValues( templateName=token.templateName, langCode=self.request.get("langCode"), tknID=token.tknID, tknValue=token.tknValue, whichuser=users.get_current_user(), ) n.put() self.render_template( "TokenStep1.html", { "languages": languages, "langCode": langCode, "countmap_other_language": countmap_other_language, "tokens": tokens, "currentuser": currentuser, "login": login, "logout": logout, }, )