示例#1
0
 def get(self, LangCode, TemplateName):
     q = GeneratedFiles.query(GeneratedFiles.LangCode == LangCode, GeneratedFiles.SearchName == TemplateName).order(GeneratedFiles.LangCode, GeneratedFiles.TemplateName, -GeneratedFiles.CreatedDate)
     genfile = q.get()
     if not genfile:
         q2 = GeneratedFiles.query(GeneratedFiles.LangCode == 'en', GeneratedFiles.TemplateName == TemplateName).order(GeneratedFiles.LangCode, GeneratedFiles.TemplateName, -GeneratedFiles.CreatedDate)
         genfile = q2.get()
         if not genfile:
             self.redirect("/try-it/utils/" + TemplateName)
             return
     logging.info('QQQ: FileTryHandlerAlt : %s' % 'just before blob_info get')
     blob_info = blobstore.BlobInfo.get(genfile.blob)
     logging.info('QQQ: FileTryHandlerAlt : %s' % 'just after blob_info get')
     self.send_blob(blob_info, content_type='text/html')
     logging.info('QQQ: FileTryHandlerAlt : %s' % 'just after blob_info send')
示例#2
0
    def post(self):

        committer = Committer("SkGithubBot", secret_botpassword, "EduExport", "master")
        items = []

        langcode = self.request.get('langcode')
        all = GeneratedFiles.query(GeneratedFiles.LangCode == langcode).fetch()
        for generated in all:
            if not generated or not generated.blob:
                logger.error("GeneratedFiles %s does not have a blob, or could not be found." % identifier)
                return
            else:
                blobinfo = blobstore.BlobInfo.get(generated.blob) 
                reader = blobinfo.open()
                content = reader.read()
                path = ""
                try:
                    path = generated.LangCode + "/"  + generated.FileGenPath + "/" + generated.FileName
                except TypeError:
                    path = generated.LangCode + "/NOPATH/"  + generated.SearchName
                path = path.replace("\\", "/")
                items.append({
                    "path": path,
                    "mode": "100644",
                    "content": content,
                })

        committer.commit(items)
    def get(self, langCode):
        self.session['langCode'] = langCode
        langName=self.request.get('langName')
        # logging.info('LLL: q in LearnUnitList: %s' % 'Now in LearnUnitGenList')
        langDictDemo = {}
        langDictDemo['en'] = 'Math / Arithmetic and Pre-algebra / Decimals - Exercises in English'
        langDictDemo['de'] = 'Mathe / Arithmetik und Pre-algebra / Dezimalen - Exercises in German'
        langDictDemo['nl'] = 'Wiskunde / Rekenen en Pre-algebra / Decimalen - Exercises in Dutch'
        langDictDemo['zh'] = '数学 / 算术和初等代数 / 小数 - Exercises in Chinese'
        langDictDemo['cs'] = 'Matematika / Aritmetika / Desetinná čísla - Exercises in Czech'
        langDictDemo['pl'] = 'Matematyka / Arytmetyka i wstęp do algebry / Liczby dziesiętne - Exercises in Polish'
        langDictDemo['bg'] = 'Математика / Аритметика и Въведение в Алгебра / Decimals - Exercises in Bulgarian'
        PageTitle = langDictDemo[langCode]

        q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Subject == 'Decimals').order(LearningUnits.Seq, LearningUnits.Name)
        # logging.info('LLL: q in LearnUnitList: %s' % q)
        units = q.fetch(999)

        # unitcnt = 0
        # for uni in units:
            # logging.info('QQQ: uni.LearningUnitID in LearnUnitList: %s' % uni.LearningUnitID)
            # unitcnt = unitcnt + 1
        # logging.info('QQQ: unitcnt in LearnUnitList: %d' % unitcnt)

        GenFiles = self.session.get('TryReadyAllFiles')
        if not GenFiles:
            gf = GeneratedFiles.query()
            GenFiles = gf.fetch(999)
            self.session['TryReadyAllFiles'] = GenFiles 
        dictTryReadyFiles = {}
        # logging.info('GGG: UnitList/dictTryReadyFiles.langCode: %s' % langCode)
        if GenFiles:
            for GenFile in GenFiles:
                if GenFile.TemplateName:
                    # logging.info('GGG: UnitList/dictTryReadyFiles.TemplateName: %s' % GenFile.TemplateName)
# #                    logging.info('GGG: UnitList/dictTryReadyFiles.FolderName: %s' % GenFile.FolderName)
                    # logging.info('GGG: UnitList/dictTryReadyFiles.SearchName: %s' % GenFile.SearchName)
                    dictTryReadyFiles[GenFile.TemplateName] = GenFile.SearchName

        # dictTryReadyFiles = {}
        # # logging.info('GGG: UnitList/dictTryReadyFiles.langCode: %s' % langCode)
        # gf = GeneratedFiles.query(GeneratedFiles.LangCode == langCode)
        # GenFiles = gf.fetch(999)
        # if GenFiles:
            # for GenFile in GenFiles:
                # if GenFile.TemplateName:
                    # # logging.info('GGG: UnitList/dictTryReadyFiles.TemplateName: %s' % GenFile.TemplateName)
# # #                    logging.info('GGG: UnitList/dictTryReadyFiles.FolderName: %s' % GenFile.FolderName)
                    # # logging.info('GGG: UnitList/dictTryReadyFiles.SearchName: %s' % GenFile.SearchName)
                    # dictTryReadyFiles[GenFile.TemplateName] = GenFile.SearchName
                    
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/units' )
        else:
              login = users.create_login_url('/units')

        self.render_template('LearnUnitGenList.html', {'units': units, 'dictTryReadyFiles':dictTryReadyFiles, 'PageTitle':PageTitle, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
示例#4
0
    def get(self, langCode):
        self.session['langCode'] = langCode
        langName=self.request.get('langName')
        logging.info('LLL: q in LearnUnitList: %s' % 'Now in LearnUnitGenList')
        langDictDemo = {}
        langDictDemo['en'] = 'Math / Arithmetic and Pre-algebra / Decimals - Exercises in English'
        langDictDemo['hu'] = 'Math / Arithmetic and Pre-algebra / Decimals - Exercises in Hungarian'
        langDictDemo['id'] = 'Math / Arithmetic and Pre-algebra / Decimals - Exercises in Indonesian'
        langDictDemo['no'] = 'Math / Aritmetikk og Pre-algebra / Desimaler - Exercises in Norwegian'
        langDictDemo['fr'] = 'Mathématiques / Arithmétique et pre-algèbre / Décimales - Exercises in French'
        langDictDemo['da'] = 'Math / Aritmetik og Pre-algebra / Decimaler - Exercises in Danish'
        langDictDemo['es'] = 'Matemáticas / Aritmética y álgebra Pre- / Decimales - Exercises in Spanish'
        langDictDemo['vi'] = 'Toán / Số học và đại số cơ bản / Thập phân - Exercises in Vietnamese'
        langDictDemo['sk'] = 'Matematika / Aritmetický a Pre-algebra / Desatinných - Exercises in Slovak'
        langDictDemo['it'] = 'Matematica / Aritmetica e pre-algebra / Decimali - Exercises in Italian'
        langDictDemo['de'] = 'Mathe / Arithmetik und Pre-algebra / Dezimalen - Exercises in German'
        langDictDemo['nl'] = 'Wiskunde / Rekenen en Pre-algebra / Decimalen - Exercises in Dutch'
        langDictDemo['ru'] = 'Математика / RАрифметика и начало алгебры / Десятичные дроби - Exercises in Russian'
        langDictDemo['zh'] = '数学 / 算术和初等代数 / 小数 - Exercises in Chinese'
        langDictDemo['cs'] = 'Matematika / Aritmetika / Desetinná čísla - Exercises in Czech'
        langDictDemo['pl'] = 'Matematyka / Arytmetyka i wstęp do algebry / Liczby dziesiętne - Exercises in Polish'
        langDictDemo['bg'] = 'Математика / Аритметика и Въведение в Алгебра / Decimals - Exercises in Bulgarian'
        PageTitle = langDictDemo[langCode]

        q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Subject == 'Decimals').order(LearningUnits.Seq, LearningUnits.Name)
        logging.info('LLL: q in LearnUnitList: %s' % q)
        units = q.fetch(999)

        unitcnt = 0
        for uni in units:
#            logging.info('QQQ: uni.LearningUnitID in LearnUnitList: %s' % uni.LearningUnitID)
            unitcnt = unitcnt + 1
        logging.info('QQQ: unitcnt in LearnUnitList: %d' % unitcnt)

        dictTryReadyFiles = {}
        logging.info('GGG: UnitList/dictTryReadyFiles.langCode: %s' % langCode)
        gf = GeneratedFiles.query(GeneratedFiles.LangCode == langCode)
        GenFiles = gf.fetch(999)
        if GenFiles:
            for GenFile in GenFiles:
                if GenFile.TemplateName:
#                    logging.info('GGG: UnitList/dictTryReadyFiles.TemplateName: %s' % GenFile.TemplateName)
#                    logging.info('GGG: UnitList/dictTryReadyFiles.FolderName: %s' % GenFile.FolderName)
#                    logging.info('GGG: UnitList/dictTryReadyFiles.SearchName: %s' % GenFile.SearchName)
                    dictTryReadyFiles[GenFile.TemplateName] = GenFile.SearchName
                    
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/units' )
        else:
              login = users.create_login_url('/units')

        self.render_template('LearnUnitGenList.html', {'units': units, 'dictTryReadyFiles':dictTryReadyFiles, 'PageTitle':PageTitle, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})
示例#5
0
    def get(self):
        genfiles = GeneratedFiles.query(GeneratedFiles.BlobKey != None).order(GeneratedFiles.BlobKey, GeneratedFiles.TemplateName)

#        genfiles = GeneratedFiles.get()
        
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/genfiles' )
        else:
              login = users.create_login_url('/genfiles')
        self.render_template('GenFileInfoList.html', {'genfiles': genfiles, 'currentuser':currentuser, 'login':login, 'logout': logout})
示例#6
0
    def get(self):
        genfiles = GeneratedFiles.query().order(GeneratedFiles.TemplateName)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/genfiles' )
        else:
              login = users.create_login_url('/genfiles')
        jinja_environment = \
            jinja2.Environment(autoescape=False, loader=jinja2.FileSystemLoader(TEMPLATE_DIR))
        self.render_template('GenFileList.html', {'genfiles': genfiles, 'currentuser':currentuser, 'login':login, 'logout': logout})
示例#7
0
    def get(self):
        TemplateName=self.request.get('TemplateName')
        LangCode=self.request.get('LangCode')
        q = GeneratedFiles.query(GeneratedFiles.LangCode == LangCode, GeneratedFiles.TemplateName == TemplateName).order(GeneratedFiles.LangCode, GeneratedFiles.TemplateName, -GeneratedFiles.CreatedDate)
        genfile = q.get()

        if genfile:
            TextOut = genfile.FileTxt.decode('utf-8')
        else:
            TextOut = 'No such file.'
#            genfile = 'No such file.'
        
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/templates' )
        else:
              login = users.create_login_url('/templates')
        self.render_template('GenFileDisplay.html', {'genfile': genfile, 'TextOut': TextOut, 'currentuser':currentuser, 'login':login, 'logout': logout})
示例#8
0
    def get(self):

        templateName=self.request.get('templateName')
        langCode=self.request.get('langCode')

        if self.request.get('extyp'):
            extyp=self.request.get('extyp')
            self.session['extyp'] = extyp
        else:
            extyp = self.session.get('extyp')
        if not extyp:
            self.session['extyp'] = 'exercise'

        q = Templates.query(Templates.Name == templateName)
        template = q.get()
#        template = ndb.Key('Templates', iden).get()
        FolderName = template.FolderName
        FileName = template.FileName
        logging.info('RRR: template.TemplateType: %s' % template.TemplateType)
        logging.info('RRR: template.Name: %s' % template.Name)
        logging.info('RRR: template.FileName: %s' % template.FileName)
        logging.info('RRR: template.FolderName: %s' % template.FolderName)
        
        SearchName = ''
        if template.TemplateType == 'exercise':
            logging.info('RRR: INSIDE IF - template.TemplateType: %s' % template.TemplateType)
            SearchName = FileName
        elif template.TemplateType == 'none':
            logging.info('RRR: INSIDE IF / elif - template.TemplateType: %s' % template.TemplateType)
            SearchName = FileName
        else:
            logging.info('RRR: INSIDE FAILED IF - template.TemplateType: %s' % template.TemplateType)
            SearchName = template.FolderName + '/' + template.FileName
        logging.info('RRR: template.SearchName: %s' % SearchName)
        fName = template.FileName
        FileGenPath = template.FileGenPath

        q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.templateName, TokenValues.tknID)
        tokenvals = q.fetch(999)
        tokendict = {}
        for tokenval in tokenvals:
            tokendict[tokenval.tknID] = tokenval.tknValue
            logging.info('QQQ: TknID: %s' % tokenval.tknID)
            logging.info('QQQ: tknValue: %s' % tokenval.tknValue)
        #tokenvals = tokendict()

        currentuser = users.get_current_user()

        q = GeneratedFiles.query(GeneratedFiles.LangCode == langCode, GeneratedFiles.TemplateName == templateName)
        genfiles = q.fetch(9)
        if genfiles:
            for genfile in genfiles:
                genfile.key.delete()

        TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'tokenizedtemplates')
        jinja_environment = \
            jinja2.Environment(autoescape=False, loader=jinja2.FileSystemLoader(TEMPLATE_DIR))
        logging.info('QQQ: FileName: %s' % FileName)
        template = jinja_environment.get_template(FileName)
#        self.response.out.write(template.render(tokenvals = tokendict)) 
        
        blobtext = template.render(tokenvals = tokendict)
        bloboutput = (blobtext.encode('utf-8'))
        
        # Create the file
        file_name = files.blobstore.create(mime_type='application/octet-stream')
        # Open the file and write to it
        with files.open(file_name, 'a') as fl:
            fl.write(blobtext)
        # Finalize the file. Do this before attempting to read it.
        files.finalize(file_name)
        # Get the file's blob key
        blob_key = files.blobstore.get_blob_key(file_name)
        logging.info('QQQ: blob_key: %s' % blob_key)

        f = GeneratedFiles(
            TemplateName = templateName
            , FolderName = FolderName
            , SearchName = SearchName
            , LangCode = langCode
            , FileName = fName
            , FileGenPath = FileGenPath
            , FileTxt = bloboutput
            , FileTxt2 = bloboutput
            , Status = 'Published'
            , blob = blob_key                       
            )
        f.put()
        TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates')
        jinja_environment = \
            jinja2.Environment(autoescape=False, loader=jinja2.FileSystemLoader(TEMPLATE_DIR))
        return self.redirect('/tokens?templateName=' + templateName + '&langCode=' + langCode)
示例#9
0
    def get(self):
        #langCode='en'

        if self.request.get('langCode'):
            langCode=self.request.get('langCode')
            self.session['langCode'] = langCode
        else:
            langCode = self.session.get('langCode')

        if self.request.get('templateName'):
            templateName=self.request.get('templateName')
            self.session['templateName'] = templateName
        else:
            templateName = self.session.get('templateName')

        if self.request.get('extyp'):
            extyp=self.request.get('extyp')
            self.session['extyp'] = extyp
        else:
            extyp = self.session.get('extyp')
        if not extyp:
            self.session['extyp'] = 'exercise'

        if self.request.get('StatusFilter'):
            StatusFilter=self.request.get('StatusFilter')
            self.session['StatusFilter'] = StatusFilter
        else:
            StatusFilter = self.session.get('StatusFilter')
        if not StatusFilter:
            self.session['StatusFilter'] = 'all'
            StatusFilter = 'all'

        if self.request.get('TopGrpFilter'):
            TopGrpFilter=self.request.get('TopGrpFilter')
            self.session['TopGrpFilter'] = TopGrpFilter
        else:
            TopGrpFilter = self.session.get('TopGrpFilter')
        if not TopGrpFilter:
            self.session['TopGrpFilter'] = 'all'
            TopGrpFilter = 'all'

        countmap_en=0
        langCode_en = 'en'
        q = TokenValues.query(TokenValues.langCode == langCode_en, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.tknID)
        tokens = q.fetch(999, keys_only=True)
#        tokens = TokenValues.all().filter('langCode =', langCode_en)
        for token in tokens:
#            logging.info('QQQ: token_en: %s' % token.langCode)
            countmap_en=countmap_en+1

        countmap_other_language=0
        if langCode != 'en':    
            q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.tknID)
            tokens = q.fetch(999, keys_only=True)
#		tokens = TokenValues().all().filter('langCode =', langCode)
            for token in tokens:
#                logging.info('QQQ: token_non-EN: %s' % token.langCode)
                countmap_other_language=countmap_other_language+1

#        languages = Languages.all().filter('langCode =', langCode)
        q = Languages.query().order(Languages.langName)
        languages = q.fetch(999)

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName, TokenValues.Status != 'Published')
        TokensNotReady = q.get()

        if TokensNotReady:
            TemplateGenReady = False
        else:        
            TemplateGenReady = True
        
        q = GeneratedFiles.query(GeneratedFiles.LangCode == langCode, GeneratedFiles.TemplateName == templateName).order(-GeneratedFiles.CreatedDate)
        GenFile = q.get()

        if GenFile:
            GenFileReady = GenFile.key.id()
            SearchName = GenFile.SearchName
        else:        
            GenFileReady = None
            SearchName = None

        logging.info('GGG: StatusFilter in TokenList: %s' % StatusFilter)
        if StatusFilter == 'all':
            q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName).order(TokenValues.langCode, TokenValues.templateName, TokenValues.tknID)
        else:
            q = TokenValues.query(TokenValues.langCode == langCode, TokenValues.templateName == templateName, TokenValues.Status == StatusFilter).order(TokenValues.langCode, TokenValues.templateName, TokenValues.tknID)
        tokens = q.fetch(999)

        if StatusFilter == 'all':
            f = TokenValues.query(TokenValues.langCode == 'en', TokenValues.templateName == templateName)
        else:
            f = TokenValues.query(Subjects.LangCode == 'en', TokenValues.templateName == templateName, TokenValues.Status == StatusFilter)

        units_en = f.fetch(999)
        
        dict_units_en = {}
        dict_units_en['DummyTemplate'] = 'no content'
        dict_Context_en = {}
        dict_Context_en['DummyTemplate'] = 'no content'
        for unit_en in units_en:
#            logging.info('GGG: Subjects.py/LearningUnitID: %s' % unit_en.LearningUnitID)
#            logging.info('GGG: Subjects.py/Description: %s' % unit_en.Description)
#            if unit_en.Context:
#                dict_units_en[unit_en.tknID] = unit_en.tknValue + ' in (' + unit_en.Context + ')'
#            else:
#                dict_units_en[unit_en.tknID] = unit_en.tknValue
            dict_units_en[unit_en.tknID] = unit_en.tknValue
            dict_Context_en[unit_en.tknID] = unit_en.Context

        TryReady = False
        if GenFile:
            GenFileReady = GenFile.key.id()
            SearchName = GenFile.SearchName
            q2 = Templates.query(Templates.Name == GenFile.TemplateName)
            GenFileTemplate = q2.get()
            if GenFileTemplate.TemplateType == 'exercise':
                TryReady = True
            else:
                TryReady = False
        else:        
            GenFileReady = None
            SearchName = None
            TryReady = False
        logging.info('GGG: Token.py/TryReady: %s' % TryReady)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/tokens' )
        else:
              login = users.create_login_url('/tokens')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('TokenListEdit.html', {'tokens': tokens, 'langName':langName, 'extyp':extyp, 'count_en':countmap_en, 'count_other_language':countmap_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'TopGrpFilter':TopGrpFilter, 'templateName':templateName, 'dict_units_en':dict_units_en, 'dict_Context_en':dict_Context_en, 'languages':languages, 'langCode':langCode, 'SearchName':SearchName, 'TryReady':TryReady, 'GenFileReady':GenFileReady, 'TemplateGenReady':TemplateGenReady, 'currentuser':currentuser, 'login':login, 'logout': logout})
    def get(self):
#        UnitSeqRecalc()
#        UnitSubjRecalc()
#        UnitTemplateSync()
        languages = memcache.get("languages")
        if languages is not None:
            logging.info("get languages from memcache.")
        else:
            q = Languages.query().order(Languages.langName)
            languages = q.fetch(99)
            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' 
            langCode = 'en'

        langName = 'no language'
        for language in languages:
            if language.langCode == langCode:
                langName = language.langName

        if self.request.get('StatusFilter'):
            StatusFilter=self.request.get('StatusFilter')
            self.session['StatusFilter'] = StatusFilter
        else:
            StatusFilter = self.session.get('StatusFilter')
        if not StatusFilter:
            self.session['StatusFilter'] = 'all'
            StatusFilter = 'all'

       # if self.request.get('SubjFilter'):
           # SubjFilter=self.request.get('SubjFilter')
           # self.session['SubjFilter'] = SubjFilter
       # else:
           # SubjFilter = self.session.get('SubjFilter')
       # if not SubjFilter:
           # self.session['SubjFilter'] = 'all'
           # SubjFilter = 'all'

        if self.request.get('TopGrpFilter'):
            TopGrpFilter=self.request.get('TopGrpFilter')
            self.session['TopGrpFilter'] = TopGrpFilter
        else:
            TopGrpFilter = self.session.get('TopGrpFilter')
        if not TopGrpFilter:
            self.session['TopGrpFilter'] = 'all'
            TopGrpFilter = 'all'

        count_en = 0
        logging.info('QQQ: Total-Outside-1 unitCount_en: %d' % count_en)
        count_en = self.session.get('unitCount_en')
        logging.info('QQQ: Total-Outside-2 unitCount_en: %d' % count_en)
        if count_en < 1:
            count_en = 0
            langCode_en = 'en'
            q = LearningUnits.query(LearningUnits.LangCode == 'en')
            units = q.fetch(999)
            for unit in units:
    #            logging.info('QQQ: count_en: %d' % count_en)
                count_en = count_en + 1
            logging.info('QQQ: Total unitCount_en: %d' % count_en)
            self.session['unitCount_en'] = 'count_en'
        logging.info('QQQ: Total-Outside-3 unitCount_en: %d' % count_en)

        count_other_language = self.session.get('unitCount_other_language')
        if not count_other_language:
            logging.info('QQQ: unitCount_other_language-langCode: %s' % langCode)
            count_other_language = 0
            q2 = LearningUnits.query(LearningUnits.LangCode == langCode)
            unitsx = q2.fetch(999)
            for unit in unitsx:
    #            logging.info('QQQ: count_other_language: %d' % count_other_language)
                count_other_language = count_other_language + 1
            logging.info('QQQ: Total count_other_language: %d' % count_other_language)
            self.session['unitCount_other_language'] = 'count_other_language'
        logging.info('QQQ: Total-Outside count_other_language: %d' % count_other_language)

        logging.info('LLL: StatusFilter in LearnUnitList: %s' % StatusFilter)
        logging.info('LLL: TopGrpFilter in LearnUnitList: %s' % TopGrpFilter)
        logging.info('LLL: langCode in LearnUnitList: %s' % langCode)
        #TopGrpFilter = 'all'
        #StatusFilter = 'all'
        if StatusFilter == 'all':
            if TopGrpFilter == 'all':
                logging.info('LLL: in LearnUnitList: now in all/all')
                q = LearningUnits.query(LearningUnits.LangCode == 'en').order(LearningUnits.Seq, LearningUnits.LearningUnitID)
            else:
                logging.info('LLL: in LearnUnitList: now in all/TopGrpFilter')
                q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Subject == TopGrpFilter).order(LearningUnits.Seq, LearningUnits.LearningUnitID)
        else:
            if TopGrpFilter == 'all':
                logging.info('LLL: in LearnUnitList: now in StatusFilter/all')
                q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Status == StatusFilter).order(LearningUnits.Seq, LearningUnits.LearningUnitID)
            else:
                logging.info('LLL: in LearnUnitList: now in StatusFilter/TopGrpFilter')
                q = LearningUnits.query(LearningUnits.LangCode == langCode, LearningUnits.Status == StatusFilter, LearningUnits.Subject == TopGrpFilter).order(LearningUnits.Seq, LearningUnits.LearningUnitID)
#        q = LearningUnits.query(LearningUnits.LangCode == langCode_en, LearningUnits.Subject == 'Math').order(LearningUnits.LearningUnitID)
        logging.info('LLL: q in LearnUnitList: %s' % q)

        units = q.fetch(999)
        # unitcnt = 0
        # for uni in units:
            # logging.info('QQQ: uni.LearningUnitID in LearnUnitList: %s' % uni.LearningUnitID)
            # unitcnt = unitcnt + 1
        # logging.info('QQQ: unitcnt in LearnUnitList: %d' % unitcnt)

        dictTryReadyFiles = {}
        logging.info('GGG: UnitList/dictTryReadyFiles.langCode: %s' % langCode)
        gf = GeneratedFiles.query(GeneratedFiles.LangCode == langCode)
        GenFiles = gf.fetch(999)
        if GenFiles:
            for GenFile in GenFiles:
                if GenFile.TemplateName:
                    logging.info('GGG: UnitList/dictTryReadyFiles.TemplateName: %s' % GenFile.TemplateName)
#                    logging.info('GGG: UnitList/dictTryReadyFiles.FolderName: %s' % GenFile.FolderName)
                    logging.info('GGG: UnitList/dictTryReadyFiles.SearchName: %s' % GenFile.SearchName)
                    dictTryReadyFiles[GenFile.TemplateName] = GenFile.SearchName

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/units' )
        else:
              login = users.create_login_url('/units')

        StatusList = ['Pending Translation', 'Pending Review', 'Published'];

        self.render_template('LearnUnitList.html', {'units': units, 'count_en': count_en, 'count_other_language': count_other_language, 'StatusList':StatusList, 'StatusFilter':StatusFilter, 'TopGrpFilter':TopGrpFilter, 'dictTryReadyFiles':dictTryReadyFiles, 'languages':languages, 'langCode':langCode, 'langName':langName, 'currentuser':currentuser, 'login':login, 'logout': logout})