当前位置: 首页>>代码示例>>Python>>正文


Python config.JINJA_ENVIRONMENT类代码示例

本文整理汇总了Python中config.JINJA_ENVIRONMENT的典型用法代码示例。如果您正苦于以下问题:Python JINJA_ENVIRONMENT类的具体用法?Python JINJA_ENVIRONMENT怎么用?Python JINJA_ENVIRONMENT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JINJA_ENVIRONMENT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

    def get(self):
    	logging.info("GET Request for MainHandler called. Pathname: " + self.request.path)

        current_page = ""
        
        #For now, the only pathnames that will succeed in the try-block are "/about", "/places", "/contact", "/guestbook",
        #and "/index".
        #All other pathnames (e.g. "/", "/about.html", "/blhahlsdu") should enter
        #the except-block and be redirected to the index page.
        try:
            if self.request.path.islower() == False:
                raise Exception ('pathname must be all lower case')
            template = JINJA_ENVIRONMENT.get_template("templates/" + self.request.path + ".html")
            #current_page should end up being one of the following four values: "INDEX", "ABOUT", "PLACES", "CONTACT"
            current_page = self.request.path[1:].upper()
        except:
            logging.info("Redirecting to index.html")
            template = JINJA_ENVIRONMENT.get_template("templates/index.html")
            current_page = "INDEX"

        
        login_status = loginStatus(self.request.path)

        self.response.write(template.render({"current_page": current_page, "logged_in": login_status['logged_in'], 
                                             "log_url": login_status['log_url']}))
开发者ID:abdulaliumich,项目名称:ali-portfolio,代码行数:25,代码来源:main.py

示例2: get

    def get(self):
        """get; show page with config values"""

        template = JINJA_ENVIRONMENT.get_template('templates/settings/detail.html')

        data = { 'config': Configuration() }
        self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:7,代码来源:settings.py

示例3: get

 def get(self):
     template_values = {
         'og_url': 'http://oclp622.com',
         'og_image': 'http://oclp622.com/assets/social_network.png'
     }
     template = JINJA_ENVIRONMENT.get_template('templates/info.html')
     self.response.write(template.render(template_values))
开发者ID:oursky,项目名称:oclp,代码行数:7,代码来源:InfoHandler.py

示例4: get

    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/statuses/list.html')

        statuses = Status.all().order('order').fetch(100)

        data = { 'statuses' : statuses, 'counter': DataStoreCounter() }
        self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:7,代码来源:statuses.py

示例5: get

 def get(self, range_id, model_id):
     template = JINJA_ENVIRONMENT.get_template('templates/carmodels/model_detail.html')
     model_range = ModelRange.get(range_id)
     car_model = CarModel.get(model_id)
     data = {
         'range': model_range,
         'model': car_model
     }
     self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:9,代码来源:carmodels.py

示例6: get

    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/start.html')


        data = {
            'counter': utils.counter.DataStoreCounter(),
            'signed_up': self.members_with_status(constants.SIGNUP_STATUS_NAME),
            'welcome_letter': self.members_with_status(constants.WELCOME_LETTER_NAME)
            }
        self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:10,代码来源:main.py

示例7: post

 def post(self):
     logging.info('Guestbook post function')
     #Reference - GAE Guestbook tutorial
     template = JINJA_ENVIRONMENT.get_template("templates/guestbook.html")
     mes = GuestbookMessage(parent=ndb.Key('Guestbook', 'AliGuestbook'))
     mes.user = users.get_current_user().nickname()
     mes.message = self.request.get('message')
     mes.put()
     #Add a second to give time for message to be added to the database 
     #and appear with the rest of the messages on redirect (hacky solution for now)
     time.sleep(1)
     self.redirect('/guestbook')
开发者ID:abdulaliumich,项目名称:ali-portfolio,代码行数:12,代码来源:main.py

示例8: render_template

 def render_template(self, template, values=None):
   """Renders the template and writes this to the reponse"""
   # Would love to use default value but it is dangerous to use {}
   if not values:
     values = {}
   values['user'] = users.get_current_user()
   if values['user']:
     values['logout_url'] = users.create_logout_url(self.request.url)
   values['navigation_pages'] = self.get_navigation_pages()
   #TODO: Handle error in event that self.url does not exist
   values['current_page'] = self
   template = JINJA_ENVIRONMENT.get_template(template)
   self.response.write(template.render(values))
开发者ID:RaspberryPiFi,项目名称:CloudCode,代码行数:13,代码来源:customframework.py

示例9: get

    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/caredit/list.html')

        unknown = CarModel.all().filter('name =', 'Annet').fetch(5)
        assert len(unknown)==1
        unknown_cars = Car.all().filter('model =', unknown[0]).fetch(50)

        other = CarModel.all().filter('name =', 'Annen Alfa Romeo').fetch(5)
        assert len(other)==1
        other_cars = Car.all().filter('model =', other[0]).fetch(50)

        data = { 'cars': other_cars + unknown_cars, 'linker': LookupReg() }
        self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:13,代码来源:caredit.py

示例10: get

    def get(self):
        # List the files in the cloudstore reports dir.
        files = list()
        bucket_name = '/' + REPORT_BUCKET

        for stat in cloudstorage.listbucket(bucket_name, max_keys=100):
            date_str = datetime.datetime.fromtimestamp(stat.st_ctime).strftime('%d.%m.%Y kl %H:%M')
            report = self.get_report_from_file(stat.filename)
            files.append({ 'filename': stat.filename[len('/' + REPORT_BUCKET + '/'):], 'date': date_str, 'report': report, 'source': stat })

        # get reports in progress

        template = JINJA_ENVIRONMENT.get_template('templates/reports/list.html')
        data = { 'files': files, 'generators': report_generators }
        self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:15,代码来源:reports.py

示例11: post

    def post(self):
        """post; Save the config and show the page again"""

        config = Configuration()
        config.set('WELCOME_MAIL_SENDER', self.request.get('welcome_sender'))
        config.set('WELCOME_MAIL_SUBJECT', self.request.get('welcome_subject'))
        config.set('NOTIFICATION_MAIL_RECIPIENTS', self.request.get('notification_recipients'))
        config.set('NOTIFICATION_MAIL_SUBJECT', self.request.get('notification_subject'))
        config.set('GIRO_ACCOUNT_NO', self.request.get('account_no'))
        config.set('GIRO_SUBJECT', self.request.get('heading'))
        config.set('GIRO_TEXT', self.request.get('body'))
        config.set('GIRO_ADDRESS', self.request.get('address'))
        config.set('WELCOME_MAIL_TEXT', self.request.get('welcome_body'))
        config.set('GIRO_MESSAGE', self.request.get('giro_message'))
        template = JINJA_ENVIRONMENT.get_template('templates/settings/detail.html')

        data = { 'config': config }
        self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:18,代码来源:settings.py

示例12: post

    def post(self):
        template = JINJA_ENVIRONMENT.get_template('templates/backup/restore.html')
        self.response.write(template.render({ 'message': 'Importing ' + self.request.get('filename') } ))

        content = self.request.get('contents')
        data = json.loads(content)

        ts = datetime.datetime.now().strftime('%Y-%m-%dT%H%M%S')

        deferred.defer(task_user_restore, data['users'], _name=('users_%s' % ts))
        deferred.defer(task_config_restore, data['config'], _name=('config_%s' % ts))
        deferred.defer(task_country_restore, data['countries'], _name=('countries_%s' % ts))
        deferred.defer(task_type_restore, data['types'], _name=('types_%s' % ts))
        deferred.defer(task_status_restore, data['status'], _name=('status_%s' % ts))

        # The limit for each task is 100KB; must limit the car and member lists
        # to something manageable. Limit to 50 and 50 users, 10 and 10 car ranges
        model_list = data['modelRanges']
        work_list = list()
        counter = 0
        while len(model_list) > 0:
            work_list.append(model_list.pop())
            if len(work_list) == 10:
                counter = counter + 1
                deferred.defer(task_model_restore, work_list, _name=('car_model_%d_%s' % (counter, ts)))
                work_list = list()
        if len(work_list) > 0:
            counter = counter + 1
            deferred.defer(task_model_restore, work_list, _name=('car_model_%d_%s' % (counter, ts)))

        counter = 0
        member_list = data['members']
        work_list = list()
        while len(member_list) > 0:
            work_list.append(member_list.pop())
            if len(work_list) == 25:
                counter = counter + 1
                deferred.defer(task_member_restore, work_list, _countdown=60, _name=('members_%d_%s' % (counter, ts)))
                work_list = list()
        if len(work_list) > 0:
            counter = counter + 1
            deferred.defer(task_member_restore, work_list, _countdown=60, _name=('members_%d_%s' % (counter, ts)))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:42,代码来源:restore.py

示例13: get

    def get(self, message_id):
        query = MessageRecord.query(MessageRecord.uid == message_id)
        queryRecords = query.fetch(1)

        # Protection
        if len(queryRecords) == 0:
            self.response.status = '302'
            self.response.headers['Location'] = '/'
            return

        template_values = {
            'og_url': 'http://oclp622.com/message/{mid}'.format(mid=message_id),
            'og_image': 'http://oclp622.com/image/{mid}/large'.format(mid=message_id),
            'og_description': u'全城{up_for}!向{no_to}說不! - {author}'.format(
                up_for=queryRecords[0].field1,
                no_to=queryRecords[0].field2,
                author=queryRecords[0].author
            )
        }
        template = JINJA_ENVIRONMENT.get_template('templates/index.html')
        self.response.write(template.render(template_values))
开发者ID:oursky,项目名称:oclp,代码行数:21,代码来源:MessageHandler.py

示例14: post

    def post(self):
        template = JINJA_ENVIRONMENT.get_template('templates/loader/loader.html')

        content = self.request.get('type')

        countries = []
        if content == 'countries.csv':
            countries = self.import_countries(self.request.get('data'))

        statuses = []
        if content == 'status.csv':
            statuses = self.import_statuses(self.request.get('data'))

        types = []
        if content == 'types.csv':
            types = self.import_types(self.request.get('data'))

        if content == 'member.csv':
            self.statuslist = Status.all().fetch(100)
            self.typelist = MemberType.all().fetch(100)
            self.countrylist = Country.all().fetch(100)
            self.import_members(self.request.get('data'))

        if content == 'model_ranges.csv':
            self.import_model_range(self.request.get('data'))

        if content == 'car_models.csv':
            self.import_car_models(self.request.get('data'))

        if content == 'cars.csv':
            self.import_member_cars(self.request.get('data'))

        if content == 'users.csv':
            self.import_users(self.request.get('data'))

        self.response.write(template.render())
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:36,代码来源:load.py

示例15: get

 def get(self):
     # Delete the cookie and show the login form
     self.response.delete_cookie(COOKIE_NAME)
     template = JINJA_ENVIRONMENT.get_template('templates/selfservice/profile_login.html')
     self.response.write(template.render())
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:5,代码来源:profile.py


注:本文中的config.JINJA_ENVIRONMENT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。