本文整理汇总了Python中web.contrib.template.render_mako函数的典型用法代码示例。如果您正苦于以下问题:Python render_mako函数的具体用法?Python render_mako怎么用?Python render_mako使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_mako函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Configure
def Configure(template_dirs, module_cache_dir = '/tmp/'):
globals()['LOOKUP'] = render_mako(
directories = template_dirs,
module_directory = module_cache_dir,
output_encoding = 'utf-8',
filesystem_checks = True
)
开发者ID:wxd00d,项目名称:RPG,代码行数:7,代码来源:templating.py
示例2: __init__
def __init__(self):
self.mako_render = render_mako(
directories=[self.templates_path, ],
input_encoding='utf-8',
output_encoding='utf-8'
)
self.kw = web.input() # remove for test
开发者ID:py-web,项目名称:webpyext,代码行数:7,代码来源:webserver.py
示例3: load_ctx
def load_ctx(handler):
web.ctx.render = render_mako(
directories = [os.path.join(os.path.dirname(__file__), 'templates')],
input_encoding='utf-8',
output_encoding='utf-8')
return handler()
开发者ID:jDomenech,项目名称:ThePunchGame,代码行数:8,代码来源:main.py
示例4: GET
def GET(self):
render = render_mako(
directories=['templates'],
input_encoding=u'utf-8',
output_encoding=u'utf-8',)
mlist = [unicode(chr(x)) for x in range(65, 91)]
return render.mako(title=u'テストタイトル',
olist=mlist)
开发者ID:GunioRobot,项目名称:learning-web.py,代码行数:8,代码来源:mako_template01.py
示例5: GET
def GET(self):
print "Testing ebook2"
render = render_mako(
directories=['ebooks/ebook2'],
input_encoding='utf-8',
output_encoding='utf-8',
)
return render.ebook2()
开发者ID:kuku713,项目名称:Web,代码行数:8,代码来源:ebooksite.py
示例6: create_render
def create_render(is_superuser):
render=None
if logged():
if is_superuser == 1:
render = render_mako(
directories=['templates'],
input_encoding='utf-8',
output_encoding='utf-8',
)
else:
render = render_mako(
directories=['templates'],
input_encoding='utf-8',
output_encoding='utf-8',
)
else:
render = render_mako(
directories=['templates'],
input_encoding='utf-8',
output_encoding='utf-8',
)
return render
开发者ID:chendean,项目名称:test01,代码行数:22,代码来源:login.py
示例7: __init__
def __init__(self):
self.render = render_mako(directories=["views"], input_encoding="utf-8", output_encoding="utf-8")
开发者ID:jt6562,项目名称:wifidog-server-demo,代码行数:2,代码来源:wifidog.py
示例8: render_mako
from models import Entry, Category
from google.appengine.ext import ndb
from google.appengine.api import users
import re
urls = (
'/admin/?$', 'index',
'/admin/list/(\w+)/?$', 'list',
'/admin/create/(\w+)/?$', 'create',
'/admin/edit/(.*)/?$', 'update',
'/admin/delete/(.*)/?$', 'delete'
)
render = render_mako(
directories=['templates/shared', 'templates/admin'],
input_encoding='utf-8',
output_encoding='utf-8'
)
app = web.application(urls, globals())
app = app.gaerun()
def create_form(entity):
#todo: proper validation for tags
if entity.__class__.__name__ == 'Entry':
q = Category.query().order(Category.name)
categories = q.fetch(10)
try:
tags = reduce(lambda x,y: x + ' ' + y, entity.tags)
except:
开发者ID:sw00,项目名称:rigmarolesoup,代码行数:31,代码来源:admin.py
示例9: AppURLopener
from datetime import timedelta
from urllib import urlencode
from urllib import urlopen
from web.contrib.template import render_mako
from pagination import *
class AppURLopener(urllib.FancyURLopener):
version = "QOS /0.1"
urllib._urlopener = AppURLopener()
#render = web.template.render('/var/www/qos')
#render = web.template.render('templates')
render = render_mako(
directories=[os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'),],
input_encoding='utf-8',
output_encoding='utf-8',
)
logging.basicConfig( format='%(asctime)s:%(levelname)s:%(message)s', filename='/var/log/jennifer/jennifer.log',
datefmt='%Y-%m-%d %I:%M:%S', level=logging.DEBUG)
#DB confs
db_host = 'localhost'
db_name = 'jennifer'
db_user = 'postgres'
db_passwd = 'postgres'
urls = (
"/qos", "HandleReceivedQosMessage",
开发者ID:krelamparo,项目名称:edtrac,代码行数:31,代码来源:jennifer.py
示例10: render_mako
#!/usr/bin/env python
# coding: utf-8
import web
# import the Mako template engine
from web.contrib.template import render_mako
from aplus import session
import cgi, os
db = web.database(dbn='mysql', db='aplus', user='root', pw='root')
# 添加session全局变量,方便在模板中访问.
#render = web.template.render('templates/', cache=False)#globals={'context': session},
# use Mako template engine
render = render_mako(
directories = [os.getcwd() + '/templates'],
input_encoding = 'utf-8',
output_encoding = 'utf-8',
)
render_admin = render_mako (
directories = [os.getcwd() + '/templates/admin'],
input_encoding = 'utf-8',
output_encoding = 'utf-8',
)
web.config.debug = True
config = web.storage(
email='[email protected]',
site_name = 'A佳教育',
site_desc = '',
开发者ID:saturnisbig,项目名称:aplus,代码行数:31,代码来源:settings.py
示例11: render_mako
#coding:utf8
import os
import web
from web.contrib.template import render_mako
BASE_PATH=os.path.join(os.path.dirname(__file__),'../templates').replace('\\','/')
render = render_mako(
directories=[BASE_PATH,],
input_encoding='utf-8',
output_encoding='utf-8',
)
render_products=render_mako(
directories=[os.path.join(BASE_PATH,'products').replace('\\','/'),],
input_encoding='utf-8',
output_encoding='utf-8',
)
render_users=render_mako(
directories=[os.path.join(BASE_PATH,'users').replace('\\','/'),],
input_encoding='utf-8',
output_encoding='utf-8',
)
render_groups=render_mako(
directories=[os.path.join(BASE_PATH,'groups').replace('\\','/'),],
input_encoding='utf-8',
output_encoding='utf-8',
)
开发者ID:JohnCny,项目名称:banksaler,代码行数:30,代码来源:pc_server.py
示例12: render_mako
'''
import os, sys, web, base64, getopt
from os import path
from web.contrib.template import render_mako
import utils
from mgr import *
cfg = utils.getcfg(['cves.conf', '/etc/cves.conf'])
web.config.cfg = cfg
DEBUG = not path.isfile('RELEASE')
web.config.debug = DEBUG
web.config.rootdir = path.dirname(__file__)
web.config.db = web.database(**dict(cfg.items('db')))
web.config.render = render_mako(
directories = ['templates'], imports = ['import web'],
default_filters = ['decode.utf8'], filesystem_checks = DEBUG,
module_directory = None if DEBUG else '/tmp/mako_modules',
input_encoding = 'utf-8', output_encoding = 'utf-8')
def serve_file(filepath):
class ServeFile(object):
def GET(self):
with open(filepath, 'rb') as fi:
return fi.read()
return ServeFile
def serve_path(dirname):
class ServePath(object):
def GET(self, p):
with open(path.join(dirname, p), 'rb') as fi:
return fi.read()
开发者ID:yegle,项目名称:cves,代码行数:31,代码来源:main.py
示例13: render_mako
except pymongo.errors.ConnectionFailure, e:
print "No se pudo conectar a MongoDB: %s" % e
conn
db = conn.usuarios
db
col = db.datos
col
print conn.database_names()
print db.collection_names()
# Uso de plantillas mako
plantillas = render_mako(directories=["templates"], input_encoding="utf-8", output_encoding="utf-8")
# Expresiones regulares para los formularios
validatorEmail = form.regexp(r"\b[a-zA-Z\d._-][email protected][a-zA-Z.-]+\.[a-zA-Z]{2,4}\b", "* Correo electrónico no válido.")
validatorVISA = form.regexp(
r"([\d]{4}) ([\d]{4}) ([\d]{4}) ([\d]{4})|([\d]{4})-([\d]{4})-([\d]{4})-([\d]{4})",
"* Número tarjeta VISA no válido.",
)
login = form.Form(
form.Textbox("nombre", required=True, description="Nombre del usuario:"),
form.Textbox("apellidos", required=True, description="Apellidos:"),
form.Textbox("DNI", required=True),
form.Textbox("correo_electronico", validatorEmail, required=True, description="Correo electronico:"),
form.Dropdown(
"Dia_de_nacimiento",
开发者ID:iblancasa,项目名称:practicas3-4-DAI,代码行数:31,代码来源:practica3-4.py
示例14: render_mako
#-*-coding:utf-8 -*-
import web
import os
from web.contrib.template import render_mako
db = web.database(host="127.0.0.1",dbn="mysql",db='kiidb',user="root",pw="123456")
prefix = 'ii_'
render_app= render_mako(
directories=["templates/app"],
input_encoding='utf-8',
output_encoding='utf-8'
)
render_cms= render_mako(
directories=["templates/cms"],
input_encoding='utf-8',
output_encoding='utf-8'
)
render_ber= render_mako(
directories=["templates/menmber"],
#input_encoding='utf-8',
output_encoding='utf-8'
)
render_status = render_mako(
directories=["templates/sus"],
#input_encoding='utf-8',
output_encoding='utf-8'
开发者ID:jvfu,项目名称:webkii,代码行数:31,代码来源:setting.py
示例15: session_hook
def session_hook():
web.ctx.session = session
web.ctx.render = render_mako(directories=[ 'templates'], input_encoding='utf-8', output_encoding='utf-8')
开发者ID:flowsha,项目名称:zhwh,代码行数:3,代码来源:zhwh.py
示例16: __init__
def __init__(self, *a, **kwargs):
from mako.lookup import TemplateLookup
self._lookup = TemplateLookup(*a, **kwargs)
def __getattr__(self, name):
# Assuming all templates are html
path = name + ".html"
t = self._lookup.get_template(path)
def wrapped(*args, **kwargs):
try:
return t.render(*args, **kwargs)
except:
return exceptions.html_error_template().render()
return wrapped
if web.config.debug == True:
render = debug_render_mako(
directories=[template_directory],
input_encoding='utf-8',
output_encoding='utf-8')
else:
render = render_mako(
directories=[template_directory],
input_encoding='utf-8',
output_encoding='utf-8')
开发者ID:apanly,项目名称:gitweb.py,代码行数:27,代码来源:common.py
示例17: get_admin_render
def get_admin_render():
return render_mako(
templates_admin_root,
input_encoding='utf-8',
output_encoding='utf-8',
)
开发者ID:coderzsun,项目名称:pysample,代码行数:6,代码来源:base.py
示例18: GET
class testpage:
def GET(self):
web.header("Content-Type","text/html; charset=utf-8")
render = render_mako(directories=['static'])
return render.provjstestpage()
class provjs:
def GET(self):
web.header('Content-Type', 'application/json')
examplegraph = createPROV()
rpslist = []
rpslist.append(examplegraph.to_provJSON())
return json.dumps(rpslist)
urls = (
'/testpage', 'testpage',
'/provjs', 'provjs',
)
app = web.application(urls, globals())
render = render_mako(
directories=['static'],
input_encoding='utf-8',
output_encoding='utf-8',
)
if __name__ == "__main__": app.run()
开发者ID:huanjiayang,项目名称:provjs,代码行数:28,代码来源:provjstest.py
示例19:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import web.contrib.template as template
render = template.render_mako(directories=['py/templates'], input_encoding='utf-8',
output_encoding='utf-8')
开发者ID:patentdoc,项目名称:miniBlog,代码行数:8,代码来源:myutil.py
示例20: Fasta
from bed_utils import BlastLine
fastas = {
'rice_v6': Fasta(path + '/data/rice_v6_sorghum_v1.4/rice_v6.fasta'),
'sorghum_v1.4': Fasta(path + '/data/rice_v6_sorghum_v1.4/sorghum_v1.4.fasta'),
'brachy_v1': Fasta(path + '/data/brachy_v1_sorghum_v1.4/brachy_v1.fasta'),
}
BL2SEQ = "/usr/bin/bl2seq -p blastn -D 1 -E 2 -q -2 -r 1 -G 5 -W 7 -F %(mask)s" \
" -Y 812045000 -d 26195 -e 2.11 -i %(iseq_file)s -j %(jseq_file)s " \
"| grep -v '#' | grep -v 'WARNING' | grep -v 'ERROR' "
render = render_mako(directories=[op.join(op.dirname(__file__), 'templates')])
class Loc(object):
__slots__ = ('org', 'start', 'end', 'seqid', 'rc')
def __init__(self, org, seqid, start, end):
self.org = org
self.start = int(start)
self.end = int(end)
self.seqid = seqid
self.rc = start > end
@classmethod
def from_input(self, winput):
for loc in winput(locs=[]).locs:
r = loc.split("..")
start, end = map(int, r[2:4])
开发者ID:brentp,项目名称:find_cns,代码行数:30,代码来源:index.py
注:本文中的web.contrib.template.render_mako函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论