本文整理汇总了Python中Cheetah.Template.Template.id方法的典型用法代码示例。如果您正苦于以下问题:Python Template.id方法的具体用法?Python Template.id怎么用?Python Template.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cheetah.Template.Template
的用法示例。
在下文中一共展示了Template.id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import id [as 别名]
def get(self, id):
nickname = "[email protected]"
wk = Workspace.get_by_id(int(id))
if not wk:
self.response.out.write("No such workspace")
return
user = users.get_current_user()
if user:
nickname = user.nickname()
if wk.user.google_id != user.user_id() and not wk.demo:
self.response.out.write("Not your workspace, %s" % nickname)
return
if not user and not wk.demo:
self.redirect(users.create_login_url(self.request.uri))
else:
path = 'templates/workspace.html'
template = Template(file=path)
template.user = nickname
template.logout_url = users.create_logout_url("/")
template.wk = Workspace.get_by_id(int(id))
template.id = id
template.indent_strings = workspace.indent_strings
template.indent_styles = workspace.indent_styles
template.font_sizes = workspace.font_sizes
template.font_faces = workspace.font_faces
template.encodings = workspace.encodings
template.sample_stylesheets = css.sample_stylesheets
self.response.out.write(template)
示例2: printer
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import id [as 别名]
def printer(id):
t = Template(file='templates/print.html')
data = db[id]
t.id = id
t.name = data['name']
items = data['items']
items += ['']
n = int(math.floor(len(items) / 2.0))
item_pairs = [(k, items[n + m]) for m, k in enumerate(items[:n])]
t.item_list = item_pairs
t.since = data['since']
return str(t)