本文整理汇总了Python中util.render_template函数的典型用法代码示例。如果您正苦于以下问题:Python render_template函数的具体用法?Python render_template怎么用?Python render_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: generate_type_maps
def generate_type_maps(install_dir):
# Collect legacy code
tmp = StringIO()
c_type_maps.gen_length_array(tmp)
with template_utils.open_output(install_dir, "loci/src/of_type_maps.c") as out:
util.render_template(out, "of_type_maps.c", legacy_code=tmp.getvalue())
开发者ID:bjlee72,项目名称:loxigen,代码行数:7,代码来源:codegen.py
示例2: generate_common
def generate_common(out, name, version):
ofclasses = [x for x in build_ofclasses(version)
if not utils.class_is_message(x.name)
and not utils.class_is_action(x.name)
and not utils.class_is_oxm(x.name)
and not utils.class_is_list(x.name)]
util.render_template(out, 'common.py', ofclasses=ofclasses, version=version)
开发者ID:ederlf,项目名称:loxigen,代码行数:7,代码来源:codegen.py
示例3: admin_create_user
def admin_create_user(request, environment, session):
"""
creates a new user and adds it to the database.
Possible errortypes are:
*
May raise the following Exceptions:
*
"""
class CreateUserForm(Form):
username = TextField('Username', [validators.Required()])
password = TextField('Password', [validators.Required()])
if request.method == 'POST':
form = CreateUserForm(request.form)
if form.validate():
username = form.username.data.strip()
password = form.password.data
#TODO: hash password
u = model.user(username, password)
session.add(u)
try:
session.commit()
except IntegrityError:
return render_template("admin_create_user.htmljinja",
environment, success=False, form=form)
return redirect('/admin/users/view')
else:
return render_template("admin_create_user.htmljinja", environment,
success=False, form=form)
else:
form = CreateUserForm()
return render_template("admin_create_user.htmljinja", environment,
form=form)
开发者ID:georgemiler,项目名称:wurstgulasch,代码行数:35,代码来源:views.py
示例4: admin_delete_user
def admin_delete_user(request, environment, session, username):
"""
deletes <username>'s user object from the database
Possible errortypes are:
*
1May raise the following Exceptions:
*
"""
# don't delete admin user
if username == 'admin':
return render_template("admin_delete_user.htmljinja", environment,
success=False)
try:
user = get_user_obj(username, session)
except NoResultFound:
return render_template("admin_delete_user.htmljinja", environment,
success=False) # delete all posts by user
posts = session.query(model.post).filter(model.post.owner == user).all()
for post in posts:
session.delete(post)
# delete friends
#for friend in user.friends:
#session.delete(friend)
session.delete(user)
session.commit()
return redirect('/admin/users/view')
开发者ID:georgemiler,项目名称:wurstgulasch,代码行数:29,代码来源:views.py
示例5: get
def get(self, hash, extension=None):
q = Album.all().filter('hash =', hash)
album = q.get()
if album:
if extension:
return self.error(404)
q = Image.all().filter('album =', album)
return self.response.out.write(render_template('album.html', {
'name': album.name,
'images': q,
}))
q = Image.all().filter('hash =', hash)
image = q.get()
if image:
if not extension:
return self.response.out.write(render_template('image.html',
{ 'image': image }))
elif image.extension == extension:
return write_image(self, image.image_data, extension)
else:
return self.error(404)
return self.error(404)
开发者ID:chosak,项目名称:restful-gallery,代码行数:25,代码来源:app.py
示例6: generate_classes
def generate_classes(install_dir):
for uclass in loxi_globals.unified.classes:
with template_utils.open_output(install_dir, "loci/src/%s.c" % uclass.name) as out:
util.render_template(out, "class.c",
push_wire_types_data=push_wire_types_data(uclass))
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, uclass.name)
c_code_gen.gen_accessor_definitions(out, uclass.name)
开发者ID:Taejun,项目名称:loxigen,代码行数:8,代码来源:codegen.py
示例7: generate_lists
def generate_lists(install_dir):
for cls in of_g.ordered_list_objects:
with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
util.render_template(out, "class.c",
push_wire_types_data=None)
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, cls)
c_code_gen.gen_list_accessors(out, cls)
开发者ID:Taejun,项目名称:loxigen,代码行数:8,代码来源:codegen.py
示例8: generate_classes
def generate_classes(install_dir):
for i, chunk in enumerate(chunks(loxi_globals.unified.classes, CLASS_CHUNK_SIZE)):
with template_utils.open_output(install_dir, "loci/src/class%02d.c" % i) as out:
for uclass in chunk:
util.render_template(out, "class.c",
push_wire_types_data=push_wire_types_data(uclass))
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, uclass.name)
c_code_gen.gen_accessor_definitions(out, uclass.name)
开发者ID:jonstout,项目名称:loxigen,代码行数:9,代码来源:codegen.py
示例9: generate_classes_header
def generate_classes_header(install_dir):
# Collect legacy code
tmp = StringIO()
c_code_gen.gen_struct_typedefs(tmp)
c_code_gen.gen_new_function_declarations(tmp)
c_code_gen.gen_accessor_declarations(tmp)
with template_utils.open_output(install_dir, "loci/inc/loci/loci_classes.h") as out:
util.render_template(out, "loci_classes.h",
legacy_code=tmp.getvalue())
开发者ID:PuzzyDog,项目名称:loxigen,代码行数:10,代码来源:codegen.py
示例10: generate_header_classes
def generate_header_classes(install_dir):
for cls in of_g.standard_class_order:
if cls.find("_header") < 0:
continue
with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
util.render_template(out, "class.c",
push_wire_types_data=None)
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, cls)
c_code_gen.gen_accessor_definitions(out, cls)
开发者ID:Taejun,项目名称:loxigen,代码行数:10,代码来源:codegen.py
示例11: generate_strings
def generate_strings(install_dir):
object_id_strs = []
object_id_strs.append("of_object")
object_id_strs.extend(of_g.ordered_messages)
object_id_strs.extend(of_g.ordered_non_messages)
object_id_strs.extend(of_g.ordered_list_objects)
object_id_strs.extend(of_g.ordered_pseudo_objects)
object_id_strs.append("of_unknown_object")
with template_utils.open_output(install_dir, "loci/src/loci_strings.c") as out:
util.render_template(out, "loci_strings.c", object_id_strs=object_id_strs)
开发者ID:kwanggithub,项目名称:loxigen,代码行数:11,代码来源:codegen.py
示例12: generate_const
def generate_const(out, name, version):
groups = {}
for (group, idents) in of_g.identifiers_by_group.items():
items = []
for ident in idents:
info = of_g.identifiers[ident]
if version in info["values_by_version"]:
items.append((info["ofp_name"], info["values_by_version"][version]))
if items:
groups[group] = items
util.render_template(out, 'const.py', version=version, groups=groups)
开发者ID:kenchiang,项目名称:loxigen,代码行数:11,代码来源:codegen.py
示例13: get
def get(self):
util.save_url(self.request, self.response)
util.fill_app_attrs(self.app, self.request.uri)
label = self.request.get("label", default_value=None)
page = int(self.request.get("page", default_value="1"))
if page > 0:
self.fill_view_attrs(label, page)
self.response.out.write(util.render_template(self.app, self.view))
else:
self.view = info.MetaInfoView()
self.fill_metainfo(label)
self.response.out.write(util.render_template(self.app, self.view))
开发者ID:mnbi,项目名称:bloggerglass,代码行数:12,代码来源:listview.py
示例14: get
def get(self):
util.save_url(self.request, self.response)
util.fill_app_attrs(self.app, self.request.uri)
user_agent = self.request.headers['User-Agent']
view = self.view.type
self.view.device = device.get_device(user_agent, view)
self.response.out.write(util.render_template(self.app, self.view))
开发者ID:mnbi,项目名称:bloggerglass,代码行数:7,代码来源:menuview.py
示例15: refresh_gallery
def refresh_gallery(self):
from util import render_template
xml = render_template('gallery2.xml', photos=Photo.all())
memcache.set("gallery.xml", xml) #@UndefinedVariable
return webapp2.Response(xml, content_type='application/xml')
开发者ID:ppalucki,项目名称:shcms,代码行数:5,代码来源:dynamic.py
示例16: get
def get(self):
mode = self.session['ebs_mode']
settings = BillingSettings.get_settings(mode=mode)
rendered_response_text = render_template('index.html',
account_id=settings.account_id,
ebs_mode=mode,
default_ebs_secret_key=configuration.DEFAULT_EBS_SECRET_KEY,
amount=Decimal(str(random.randint(1000, 40000)) + '.' + str(random.randint(10, 100))),
billing_return_url=configuration.BILLING_RETURN_URL,
countries=COUNTRIES_TUPLE_MAP,
description=random.choice(TRANSACTION_DESCRIPTIONS),
ebs_secure_url=configuration.EBS_SECURE_URL,
ebs_support_email=configuration.EBS_SUPPORT_EMAIL,
ebs_support_url=configuration.EBS_SUPPORT_URL,
reference_number=random.randint(400000, 600000),
modes=MODES,
full_name=random.choice(FULL_NAMES),
city=random.choice(CITIES),
country_code=random.choice(COUNTRIES_TUPLE_MAP)[0],
email=random.choice(EMAILS),
phone_number=random.randint(9800000000, 9899999999),
postal_address=random.choice(POSTAL_ADDRESSES),
postal_code=random.randint(400000, 500000),
state_province=random.choice(STATES),
ship_full_name=random.choice(FULL_NAMES),
ship_city=random.choice(CITIES),
ship_country_code=random.choice(COUNTRIES_TUPLE_MAP)[0],
ship_email=random.choice(EMAILS),
ship_phone_number=random.randint(9800000000, 9899999999),
ship_postal_address=random.choice(POSTAL_ADDRESSES),
ship_postal_code=random.randint(400000, 500000),
ship_state_province=random.choice(STATES),
)
self.response.out.write(rendered_response_text)
开发者ID:yesudeep,项目名称:pyebs,代码行数:34,代码来源:application.py
示例17: web_view_stream_tag
def web_view_stream_tag(request, environment, session, username, tagstr,
page=1, posts_per_page=15):
"""
returns the <page> <posts_per_page> posts owned by <username> and tagged
with <tagstr> as 'posts' and the <username>'s user object as 'user'
Possible errortype values are:
*
May raise the following Exceptions:
* Exception('NoSuchUser')
* Exception('InsufficientPrivileges')
* Exception('InputMakesNoSense')
* Exception('TagNotFound')
"""
u = get_user_obj(username, session)
#identify tag
res = session.query(tag).filter(tag.tag == tagstr).all()
if res:
tag_found = res[0]
posts = tag_found.posts[(page-1)*posts_per_page:page*posts_per_page]
posts = [p.downcast() for p in posts]
posts = sorted(posts, key = lambda p: p.timestamp, reverse=True)
total_num = len(tag_found.posts)
else:
raise Exception("TagNotFound")
return render_template("web_view_stream_tag.htmljinja", environment,
posts=posts, tag=tag_found, show_tags=True, user=u,
page_num=page, total_num=total_num,
posts_per_page=posts_per_page)
开发者ID:georgemiler,项目名称:wurstgulasch,代码行数:32,代码来源:views.py
示例18: admin_reset_password
def admin_reset_password(request, environment, session, username):
"""
resets <username>'s password
Possible errortypes are:
*
May raise the following Exceptions:
*
"""
class ResetPasswordForm(Form):
password = TextField("password",
[validators.Required()])
u = get_user_obj(username, session)
if request.method == 'POST':
form = ResetPasswordForm(request.form)
if form.validate():
u.passwordhash = form.password.data
session.commit()
return redirect('/admin/users/view')
else:
form = ResetPasswordForm()
return render_template("admin_reset_password.htmljinja", environment,
success=False, user=u, form=form)
开发者ID:georgemiler,项目名称:wurstgulasch,代码行数:25,代码来源:views.py
示例19: web_view_user_posts
def web_view_user_posts(request, environment, session, username, page=1,
posts_per_page=15):
"""
returns the <page> <posts_per_page> posts created by <username> as 'posts',
<username>'s user object as 'user', an empty array if there aren't any.
Possible errortype values are:
* 'NoSuchUser' if <username> is unknown to the system.
May raise the following Exceptions:
* Exception('NoSuchUser')
"""
u = get_user_obj(username, session)
own = session.query(post.id).filter(post.owner == u.identity).subquery()
reposts = session.query(post.id).filter(
post.reposters.contains(u.identity)).subquery()
total_num = session.query(model.post).filter(or_(post.id.in_(reposts), post.id.in_(own))).count()
allposts = session.query(model.post).filter(
or_(post.id.in_(reposts), post.id.in_(own))).order_by(desc(post.timestamp)).offset((page-1)*posts_per_page).limit(posts_per_page).all()
posts = [p.downcast() for p in allposts]
return render_template("web_view_user_posts.htmljinja", environment,
posts=posts, page_num=page, total_num=total_num,
posts_per_page=posts_per_page, user=u)
开发者ID:georgemiler,项目名称:wurstgulasch,代码行数:27,代码来源:views.py
示例20: default
def default(request, environment, session):
"""
returns an empty dictionary.
Possible errortypes are:
*
May raise the following Exceptions:
*
"""
return render_template("default.htmljinja", environment)
开发者ID:georgemiler,项目名称:wurstgulasch,代码行数:10,代码来源:views.py
注:本文中的util.render_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论