• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python template.render_jinja函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getRender

def getRender():
    """ get render for public pages """
    render = render_jinja(
        'templates',                      # set template directory
        encoding = 'utf-8',               # encoding
    )
    return render
开发者ID:huoyuanzh,项目名称:aplog,代码行数:7,代码来源:config.py


示例2: getAdminRender

def getAdminRender():
    render = render_jinja(
        'tpl/admin',
        encoding = 'utf-8'
    )

    return render
开发者ID:ponych,项目名称:ponych_python,代码行数:7,代码来源:config.py


示例3: getRender

def getRender():
    render = render_jinja(
        'tpl',
        encoding = 'utf-8'
    )

    return render
开发者ID:ponych,项目名称:ponych_python,代码行数:7,代码来源:config.py


示例4: render

def render(tmp_dir):
    gconf = config.data
    gconf['uptime'] = serverInfo()
    render = render_jinja([config.pp + 'templates/', config.pp + 'templates/' + tmp_dir], encoding='utf-8')
    render._lookup.globals.update(session=web.config._session, gconf=gconf)
    render._lookup.filters.update(filter.filters)

    return render
开发者ID:fenceer,项目名称:hbible,代码行数:8,代码来源:common.py


示例5: load_render

def load_render(views, **globals):
    '''Add the renderer to the shared context.'''
    render = render_jinja(views, encoding='utf-8',
                          extensions=['jinja2.ext.do'])
    render._lookup.globals.update(globals)
    def inner():
        web.ctx.render = render;
    return inner
开发者ID:comick,项目名称:barduino,代码行数:8,代码来源:app_processors.py


示例6: rendeHtml

def rendeHtml(template, **args):
    web.header('Content-Type', 'text/html')

    globals['v'] = time.time()
    globals['cookies'] = web.cookies()

    render = render_jinja(path + '/templates', encoding='utf-8', globals=globals)
    print path + '/templates'
    return getattr(render, template)(**args)
开发者ID:m1993619,项目名称:gratuation,代码行数:9,代码来源:render.py


示例7: getAdminRender

def getAdminRender():
    render = render_jinja(
            os.getcwd() + '/templates/admin',
            encoding = 'utf-8',
        )
    myFilters = {'avatar':templatefilters.avatar,'notnull':templatefilters.notnull,
        'formnote':templatefilters.formnote, 'content':templatefilters.content}
    render._lookup.filters.update(myFilters)
    return render
开发者ID:Giiithub,项目名称:davidblog,代码行数:9,代码来源:settings.py


示例8: load_render_with_assets

def load_render_with_assets(views, env, **globals):
    '''Add the renderer to the shared context.'''
    from webassets.ext.jinja2 import AssetsExtension
    render = render_jinja(views, encoding='utf-8',
                          extensions=['jinja2.ext.do', AssetsExtension])
    render._lookup.assets_environment = env
    render._lookup.globals.update(globals)
    def inner():
        web.ctx.render = render;
    return inner
开发者ID:comick,项目名称:barduino,代码行数:10,代码来源:app_processors.py


示例9: GET

 def GET(self, templatename):
     root_path = os.environ['ROOT_PATH']
     template_path = os.path.join(root_path, 'templates')        
     try:
         templatename = 'tests/%s' % templatename
         render = template.render_jinja(template_path)
         return getattr(render, templatename, '')()
     except:
         logging.exception("got an error in loading %s" %templatename)
         return 'template %s not found' % templatename
开发者ID:nitinsensible,项目名称:zenmove-test,代码行数:10,代码来源:zen.py


示例10: render

def render(template, context, locale=None):
    if locale:
        set_locale(locale)
    jinja = render_jinja(
        TEMPLATE_PATH,
        globals={'gettext' : ugettext_for_locale(LOCALE)},
        extensions=['jinja2.ext.i18n'],
        encoding='utf-8',
        )
    jinja._lookup.filters.update(TEMPLATE_FILTERS)
    template = jinja._lookup.get_template(template)
    return template.render(**context)
开发者ID:creativecommons,项目名称:metadata_scraper,代码行数:12,代码来源:renderer.py


示例11: index

def index():
    import web
    from web.contrib.template import render_jinja
    from models import profile, database

    db = database.database()
    urls = (
                '/', 'hello'
                        )
    
    render = render_jinja(
                  'templates',                 # Set template directory.
                   encoding = 'utf-8',         # Encoding.
                           )
开发者ID:evnpr,项目名称:discussion,代码行数:14,代码来源:main.py


示例12: GET

 def GET(self, page=None):
     try:
         page = int(page) if page else 1
     except ValueError:
         page = 1
     offset = (page - 1) * PER_PAGE
     db = web.database(dbn='sqlite', db=DB)
     quote_count = db.query("select count(*) as count from quote where channel='{}'".format(CHANNEL))[0].count
     quotes = db.select('quote', where="channel = '{}'".format(CHANNEL),
                        order='date desc', limit='$l', offset='$o',
                        vars={'l': PER_PAGE, 'o': offset})
     quotes = [fixDates(quote) for quote in quotes]
     pages = int(math.ceil(quote_count / PER_PAGE))
     render = render_jinja(TEMPLATES)
     return render.list(quotes=quotes, channel=CHANNEL,
                        analytics=GOOGLE_ANALYTICS, page=page, pages=pages)
开发者ID:oyvindio,项目名称:quotes,代码行数:16,代码来源:quotes.py


示例13: render_jinja

urls = (
    '/', 'index',
    '/login', 'login',
    '/msg', 'msg',
    '/gender', 'gender',
    '/main', 'main',
    '/femain', 'femain',
   '/getMalePic', 'getMalePic',
   '/getFePic', 'getFePic',
    '/last', 'last',
    '/finalPic', 'finalPic'
)

#render = web.template.render('resource')
render = render_jinja(
        'resource',
        encoding = 'utf-8',
    )

app = web.application(urls, globals())
#web.config.debug = False
#session = web.session.Session(app, web.session.DiskStore('sessions'), initializer={'uid':0})
#session
if web.config.get('_session') is None:
    session = web.session.Session(app, web.session.DiskStore('sessions'),\
     {'uid': 0, 'color':'#444444', 'imgUrl':0})
    web.config._session = session
else:
    session = web.config._session

bksjw='http://bksjw.hust.edu.cn/'
hub='http://hub.hust.edu.cn/'
开发者ID:cxymrzero,项目名称:hustdiy,代码行数:32,代码来源:diy.py


示例14: render_jinja

        s['count'] = 1
        count = s['count']
    s['count'] = count + 1
    s.close()
    return count
    
t_globals = {
            "ctx" : web.ctx,
            "team_infor" : db.select("team_infor")[0],
            "grade_dict" : grade_dict,
            "grade_manage_dict" : grade_manage_dict,
            "gravatar_dir" : r"/static/gravatar/",
            "visitor_count" : get_visitor,
        }

render = render_jinja(os.path.join(ABSPATH,"templates/"),encoding="utf-8",globals = t_globals)
render_admin = render_jinja(os.path.join(ABSPATH,"templates/admin/"),encoding="utf-8",globals = t_globals)



app = web.application(urls,globals())
application = app.wsgifunc()

store = web.session.DBStore(db, 'sessions')
sess = web.session.Session(app, store)

class Upload(object):
    
    def __init__(self,upfile):
        import os
        self.file = upfile
开发者ID:daivlin,项目名称:footballTeam,代码行数:31,代码来源:index.py


示例15: render_jinja

import web
import os
import numpy as np
import scipy.io as sio
from sklearn.svm import SVC

from web.contrib.template import render_jinja
from process_email import process_email, email_features
from spam_train import spam_train

template_dir = os.path.join(os.path.dirname(__file__), '.')
render = render_jinja(
    template_dir,
    encoding='utf-8',
)

model = None # store model so won't have to compute over and over

class index:
    def GET(self):
        return render.front(email="", error="")

    def POST(self):
        global model
        email = web.input().email

        if not email:
            error = "we need some email contents"
            return render.front(email=email, error=error)
        else:
            features = np.reshape(email_features(process_email(email)), (1, -1))
开发者ID:jczhu,项目名称:spam_proj,代码行数:31,代码来源:spam_checker.py


示例16: render_jinja

import web
import json
import core

from models import *
from web.contrib.template import render_jinja

view = render_jinja('view/visitor')

class create:
    def GET(self):
        return view.signup(user = User.status())

    def POST(self):
        """
        @return: json(@error)
        """
        try:
            User.create(dict(web.input()))
            return json.dumps({'error': 0})
        except AttributeError:
            # Missing information
            return json.dumps({'error': 1})
        except Exception as exception:
            errorCode =  int(exception.message)
            if errorCode > 1:
                return json.dumps({'error': errorCode})
            else:
                # Unknown error
                return json.dumps({'error': 9999})
开发者ID:imdreamrunner,项目名称:VCBank,代码行数:30,代码来源:account.py


示例17: render_jinja

    'social.backends.tripit.TripItOAuth',
    'social.backends.twilio.TwilioAuth',
    'social.backends.xing.XingOAuth',
    'social.backends.yandex.YandexOAuth2',
)
web.config[setting_name('LOGIN_REDIRECT_URL')] = '/done/'


urls = (
    '^/$', 'main',
    '^/done/$', 'done',
    '', social_app.app_social
)


render = render_jinja('templates/')


class main(object):
    def GET(self):
        return render.home()


class done(social_app.BaseViewClass):
    @strategy()
    def GET(self):
        user = self.get_current_user()
        return render.done(user=user, backends=backends(user))


engine = create_engine('sqlite:///test.db', echo=True)
开发者ID:kazarinov,项目名称:python-social-auth,代码行数:31,代码来源:app.py


示例18: globals

import web
from web.contrib.template import render_jinja
import json

import ip_find

urls = ("/ip", "IPFind",
        "/api/ip/(.*)", "IPFindAPI")

app = web.application(urls, globals())
render = render_jinja("templates", encoding='utf-8')
ipInfo = ip_find.IPInfo("data/qqwry.dat")

def find_loc_by_ip(ip):
    try:
        i = ipInfo
        (c, a) = i.getIPAddr(ip);
        c = unicode(c, 'utf-8')
        a = unicode(a, 'utf-8')
    except:
        raise
    return (c, a)

class IPFind:
    def GET(self):
        return render.ip()

class IPFindAPI:
    def GET(self, ip):
        try:
            c, a = find_loc_by_ip(ip)
开发者ID:progresstudy,项目名称:ip_location,代码行数:31,代码来源:index.py


示例19: render_jinja

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Created on 20101205
Author: zkz
"""
from ua.common.bridge import moni as bridge_moni

import web
from web.contrib.template import render_jinja

urls = ("/page", "Page")

render = render_jinja("webapps/syst/templates/moni", encoding="utf-8")
app = web.application(urls, locals())


def notfound():
    return web.notfound(render.notfound())


app.notfound = notfound


def login_required(func):
    def new_func(*args, **argvkw):
        session = web.ctx.session
        if session.user == "anonymous" or session.user == "":
            #            return render.notlogin()
            raise web.seeother("/login?tip=%s" % u"请登录!")
        else:
开发者ID:e42s,项目名称:uss,代码行数:31,代码来源:moni.py


示例20: render_jinja

    "social.backends.tripit.TripItOAuth",
    "social.backends.clef.ClefOAuth2",
    "social.backends.twilio.TwilioAuth",
    "social.backends.xing.XingOAuth",
    "social.backends.yandex.YandexOAuth2",
    "social.backends.podio.PodioOAuth2",
    "social.backends.mineid.MineIDOAuth2",
    "social.backends.wunderlist.WunderlistOAuth2",
)
web.config[setting_name("LOGIN_REDIRECT_URL")] = "/done/"


urls = ("^/$", "main", "^/done/$", "done", "", social_app.app_social)


render = render_jinja("templates/")


class main(object):
    def GET(self):
        return render.home()


class done(social_app.BaseViewClass):
    def GET(self):
        user = self.get_current_user()
        return render.done(user=user, backends=backends(user))


engine = create_engine("sqlite:///test.db", echo=True)
开发者ID:webjunkie,项目名称:python-social-auth,代码行数:30,代码来源:app.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python template.render_mako函数代码示例发布时间:2022-05-26
下一篇:
Python app.run函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap