本文整理汇总了Python中spline.lib.base.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: profile_edit_commit
def profile_edit_commit(self, id, name=None):
"""Save profile changes."""
c.page_user = meta.Session.query(users_model.User).get(id)
if not c.page_user:
abort(404)
# XXX could use some real permissions
if c.page_user != c.user:
abort(403)
c.form = ProfileEditForm(request.params,
name=c.page_user.name,
)
if not c.form.validate():
return render('/users/profile_edit.mako')
c.page_user.name = c.form.name.data
meta.Session.add(c.page_user)
meta.Session.commit()
h.flash('Saved your profile.', icon='tick')
redirect(
url(controller='users', action='profile',
id=c.page_user.id, name=c.page_user.name),
code=303,
)
示例2: threads
def threads(self, forum_id):
c.forum = meta.Session.query(forum_model.Forum).get(forum_id)
if not c.forum:
abort(404)
c.write_thread_form = WriteThreadForm()
# nb: This will never show post-less threads. Oh well!
last_post = aliased(forum_model.Post)
threads_q = c.forum.threads \
.join((last_post, forum_model.Thread.last_post)) \
.order_by(last_post.posted_time.desc()) \
.options(
contains_eager(forum_model.Thread.last_post, alias=last_post),
joinedload('last_post.author'),
)
c.num_threads = threads_q.count()
try:
c.skip = int(request.params.get('skip', 0))
except ValueError:
abort(404)
c.per_page = 89
c.threads = threads_q.offset(c.skip).limit(c.per_page)
return render('/forum/threads.mako')
示例3: skills_list
def skills_list(self):
skills = (db.pokedex_session.query(t.ConquestWarriorSkill)
.join(t.ConquestWarriorSkill.names_local)
.order_by(t.ConquestWarriorSkill.names_table.name.asc()))
# We want to split the list up between generic skills anyone can get
# and the unique skills a specific warlord gets at a specific rank.
# The two player characters throw a wrench in that though so we just
# assume any skill known only by warlords is unique, which happens to
# work.
warriors_and_ranks = sqla.orm.join(t.ConquestWarrior,
t.ConquestWarriorRank)
generic_clause = (sqla.sql.exists(warriors_and_ranks.select())
.where(sqla.and_(
t.ConquestWarrior.archetype_id != None,
t.ConquestWarriorRank.skill_id ==
t.ConquestWarriorSkill.id))
)
c.generic_skills = skills.filter(generic_clause).all()
c.unique_skills = (skills.filter(~generic_clause)
.options(
sqla.orm.joinedload('warrior_ranks'),
sqla.orm.joinedload('warrior_ranks.warrior')
)
.all())
# Decide randomly which player gets displayed
c.player_index = randint(0, 1)
return render('/pokedex/conquest/skill_list.mako')
示例4: whos_that_pokemon
def whos_that_pokemon(self):
u"""A silly game that asks you to identify Pokémon by silhouette, cry,
et al.
"""
c.javascripts.append(('pokedex', 'whos-that-pokemon'))
return render('/pokedex/gadgets/whos_that_pokemon.mako')
示例5: permissions
def permissions(self):
if not c.user.can('administrate'):
abort(403)
c.roles = meta.Session.query(users_model.Role) \
.order_by(users_model.Role.id.asc()).all()
return render('/users/admin/permissions.mako')
示例6: abilities_list
def abilities_list(self):
c.abilities = (db.pokedex_session.query(t.Ability)
.join(t.Ability.names_local)
.filter(t.Ability.conquest_pokemon.any())
.order_by(t.Ability.names_table.name.asc())
.all()
)
return render('/pokedex/conquest/ability_list.mako')
示例7: kingdoms_list
def kingdoms_list(self):
c.kingdoms = (db.pokedex_session.query(t.ConquestKingdom)
.options(
sqla.orm.joinedload('type')
)
.order_by(t.ConquestKingdom.id)
.all()
)
return render('/pokedex/conquest/kingdom_list.mako')
示例8: kingdoms
def kingdoms(self, name):
try:
c.kingdom = db.get_by_name_query(t.ConquestKingdom, name).one()
except NoResultFound:
return self._not_found()
# We have pretty much nothing for kingdoms. Yet.
c.prev_kingdom, c.next_kingdom = self._prev_next_id(
c.kingdom, t.ConquestKingdom, 'id')
return render('/pokedex/conquest/kingdom.mako')
示例9: profile
def profile(self, id, name=None):
"""Main user profile.
URL is /users/id:name, where 'name' only exists for readability and is
entirely optional and ignored.
"""
c.page_user = meta.Session.query(users_model.User).get(id)
if not c.page_user:
abort(404)
return render('/users/profile.mako')
示例10: warriors_list
def warriors_list(self):
c.warriors = (db.pokedex_session.query(t.ConquestWarrior)
.options(
sqla.orm.subqueryload('ranks'),
sqla.orm.subqueryload('ranks.stats'),
sqla.orm.subqueryload('types')
)
.order_by(t.ConquestWarrior.id)
.all()
)
return render('/pokedex/conquest/warrior_list.mako')
示例11: document
def document(self):
"""Render the error document."""
# code and messae might come from GET, *or* from the Pylons response
# object. They seem to come from the latter most of the time, but
# let's be safe anyway.
response = request.environ.get('pylons.original_response')
c.message = request.GET.get('message', response and response.status)
c.code = request.GET.get('code', response and response.status_int)
c.code = int(c.code)
return render('/error.mako')
示例12: skills
def skills(self, name):
try:
c.skill = (db.get_by_name_query(t.ConquestWarriorSkill, name)
.one())
except NoResultFound:
return self._not_found()
### Prev/next for header
c.prev_skill, c.next_skill = self._prev_next_name(
t.ConquestWarriorSkill, c.skill)
return render('/pokedex/conquest/skill.mako')
示例13: css
def css(self):
"""Returns all the CSS in every plugin, concatenated."""
# This solution sucks donkey balls, but it's marginally better than
# loading every single stylesheet manually, so it stays until I have
# a better idea
response.headers['Content-type'] = 'text/css; charset=utf-8'
stylesheets = []
for css_file in config['spline.plugins.stylesheets']:
stylesheets.append(render("/css/%s" % css_file))
return '\n'.join(stylesheets)
示例14: list
def list(self):
u"""Show a list of all Pokémon currently uploaded to the GTS."""
gts_pokemons = meta.Session.query(gts_model.GTSPokemon).all()
c.savefiles = []
for gts_pokemon in gts_pokemons:
savefile = SaveFilePokemon(gts_pokemon.pokemon_blob)
savefile.use_database_session(db.pokedex_session)
c.savefiles.append(savefile)
return render('/gts/list.mako')
示例15: write_thread
def write_thread(self, forum_id):
"""Provides a form for posting a new thread."""
if not c.user.can('forum:create-thread'):
abort(403)
try:
c.forum = meta.Session.query(forum_model.Forum) \
.filter_by(id=forum_id).one()
except NoResultFound:
abort(404)
c.write_thread_form = WriteThreadForm(request.params)
return render('/forum/write_thread.mako')