本文整理汇总了Python中theory.lib.base.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: artists
def artists(self):
""" the controller for the artists frame """
try:
self.m = g.p.connect()
except (NoMPDConnection, ConnectionClosed):
return render('/null.html')
c.artists = self.m.artists()
return render('/artists.html')
示例2: streams
def streams(self,use_htmlfill=True,**kwargs):
c.error = request.GET.get('error','')
c.streams = g.tc.streams
if use_htmlfill:
return formencode.htmlfill.render(render("/streams.html"),{'name':kwargs.get('name',''),
'url':kwargs.get('url','')})
else:
return render("/streams.html")
return render('/streams.html')
示例3: artists
def artists(self):
""" the controller for the artists frame """
try:
m = g.p.connect()
except ConnectionClosed:
return render('/null.html')
c.artists = m.artists()
return render('/artists.html')
示例4: stats
def stats(self):
""" controller for the stats widget """
try:
m = g.p.connect()
except ConnectionClosed:
return render('/null.html')
c.stats = m.stats()
aa = AlbumArt()
c.dir_size = aa.dir_size()
return render('/stats.html')
示例5: fs_status
def fs_status(self):
"""
similar to status() but includes a forward-looking playlist
for the fullscreen widget
"""
try:
self.m = g.p.connect()
except ConnectionClosed:
return render('/null.html')
status = self.m.status()
current = self.m.currentsong()
playlist = self.m.playlistinfo()
track = 0
found_current = False
remaining_playlist = []
for pl in playlist:
if found_current:
remaining_playlist.append(pl)
if 'id' in current:
if pl['id'] == current['id']:
found_current = True
track += 1
#m.close()
return dict(status=status,current=current,playlist=remaining_playlist)
示例6: albums
def albums(self):
""" controller for the albums frame """
c.artist = request.GET.get('artist', u'')
c.album = request.GET.get('album', u'')
try:
self.m = g.p.connect()
except (NoMPDConnection, ConnectionClosed):
return render('/null.html')
c.albums = self.m.albums(c.artist)
aa = AlbumArt()
c.album_imgs = aa.artist_art(c.artist)
random.shuffle(c.album_imgs)
return render('/albums.html')
示例7: tracks
def tracks(self):
""" controller for the tracks frame """
c.artist = request.GET.get('artist','').encode('utf-8')
c.album = request.GET.get('album','').encode('utf-8')
try:
m = g.p.connect()
except ConnectionClosed:
return render('/null.html')
c.tracks = m.tracks(c.artist,c.album)
c.artist_safe = h.html.url_escape(c.artist)
c.album_safe = h.html.url_escape(c.album)
return render('/tracks.html')
示例8: search
def search(self):
searchtype = request.GET.get('searchtype','Artist')
q = request.GET.get('q').encode('utf-8')
if q and len(q) > 2:
m = g.p.connect()
results = m.search(searchtype,q)
c.artists = set()
c.albums = set()
c.tracks = set()
search_string = q.lower()
for r in results:
if 'artist' in r.keys() and search_string in r['artist'].lower():
c.artists.add(r['artist'])
if 'album' in r.keys() and search_string in r['album'].lower():
c.albums.add((r['artist'], r['album']))
if 'title' in r.keys() and search_string in r['title'].lower():
c.tracks.add((r['artist'], r['album'], r['title'], r['file']))
return render('/search.html')
示例9: albums
def albums(self):
""" controller for the albums frame """
c.artist = request.GET.get('artist','').encode('utf-8')
c.album = request.GET.get('album','').encode('utf-8')
try:
m = g.p.connect()
except ConnectionClosed:
return render('/null.html')
c.albums = m.albums(c.artist)
aa = AlbumArt()
c.album_imgs = aa.artist_art(c.artist)
random.shuffle(c.album_imgs)
return render('/albums.html')
示例10: index
def index(self):
""" controller for the playlist frame """
try:
self.m = g.p.connect()
except NoMPDConnection:
return render('/null.html')
status = self.m.status()
c.playlistid = status['playlist']
c.playlist = self.m.playlistinfo()
info = self.m.lsinfo()
c.available_playlists = [playlist['playlist'] for playlist in info if 'playlist' in playlist]
c.available_playlists.insert(0,'')
c.g = g
return render('/playlist.html')
示例11: add_random
def add_random(self):
m = g.p.connect()
files = request.POST.getall('file')
for f in files:
m.add(f.encode('utf-8'))
c.content = '<script language="javascript">window.parent.frames[\'frmplaylist\'].location.reload();</script>'
return render('/null.html')
示例12: filesystem
def filesystem(self):
m = g.p.connect()
c.path = request.GET.get('path','/').encode('utf-8')
c.lsinfo = m.lsinfo(c.path)
c.uppath = '/'.join(c.path.split('/')[:-1])
return render('/filesystem.html')
示例13: randomizer
def randomizer(self):
action = request.GET.get('action','')
c.incex = request.GET.get('incex','exclude')
c.selected_genres = request.GET.getall('genres')
c.exclude_live = request.GET.get('excludelive',not bool(len(action)))
c.quantity = int(request.GET.get('quantity',50))
c.genres = sorted(g.genres)
if action:
m = g.p.connect()
c.random_tracks = m.get_random_tracks(c.incex,c.selected_genres,c.exclude_live,c.quantity)
return render('/randomizer.html')
示例14: document
def document(self):
"""Render the error document"""
resp = request.environ.get('pylons.original_response')
if resp.status_int == 404:
return render('/404.html')
content = literal(resp.body) or cgi.escape(request.GET.get('message'))
page = error_document_template % \
dict(prefix=request.environ.get('SCRIPT_NAME', ''),
code=cgi.escape(request.GET.get('code', str(resp.status_int))),
message=content)
return page
示例15: config
def config(self, use_htmlfill=True):
""" controller for the configuration iframe """
c.firsttime = request.GET.get('firsttime', '0')
c.noconnection = request.GET.get('noconnection')
c.error = request.GET.get('error')
c.type = request.GET.get('type')
configured_outputs = []
if c.firsttime == '0':
try:
self.m = g.p.connect()
c.outputs = self.m.outputs()
for o in c.outputs:
if o['outputenabled'] == '1':
key = 'enabled'
else:
key = 'disabled'
configured_outputs.append({key: o['outputid']})
except ConnectionClosed:
return render('/null.html')
if use_htmlfill:
values = formencode.variabledecode.variable_encode({'firsttime': c.firsttime, 'server':g.tc.server,
'port':g.tc.port,
'password':g.tc.password,'webpassword':g.tc.webpassword,
'awskey':g.tc.awskey,'timeout':g.tc.timeout,
'aws_secret':g.tc.aws_secret,
'lastfmkey':g.tc.lastfmkey,
'default_search':g.tc.default_search,
'outputs': configured_outputs})
return formencode.htmlfill.render(render("/config.html"), values)
else:
return render("/config.html")