本文整理汇总了Python中models.Movie.all方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.all方法的具体用法?Python Movie.all怎么用?Python Movie.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Movie
的用法示例。
在下文中一共展示了Movie.all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import all [as 别名]
def get(self, name):
if not users.get_current_user():
self.redirect(users.create_login_url(self.request.uri))
results = search_metacritic(name, 'movie')
output = []
for result in results:
query = Img.all()
query.filter('url =', result[1])
img = query.fetch(1)[0]
query = Movie.all()
query.filter('cover =', img)
if not query.count():
movie = Movie(name=str(result[0]),cover=img,score=str(result[2]))
movie.put()
else:
movie = query.fetch(1)[0]
output.append([img.key().id(), result[0], movie.key().id()])
template_values = {'results': output}
path = os.path.join(os.path.dirname(__file__), 'search.html')
self.response.out.write(template.render(path, template_values))
示例2: movies
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import all [as 别名]
def movies():
if request.is_xhr:
q = Movie.all()
q.order("-votes")
limit = 11
offset = 0
if "limit" in request.form:
try:
limit = int(request.form['limit'])
except Exception, e:
pass
if "offset" in request.form:
try:
offset = int(request.form['offset'])
except Exception, e:
pass
示例3: get_movies
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import all [as 别名]
def get_movies(order, direction, minvotes, maxvotes, minrating, maxrating, total_count=20, cursor=None):
key = "[movies]%s;%s;%s;%s;%s;%s;%s;%s" % (order, direction, minvotes, maxvotes, minrating, maxrating, total_count, cursor)
movies = memcache.get(key, namespace="movies")
#if movies:
# l.info('Memcache hit in movies')
# return movies
q = Movie.all()
l.info((order, direction, minvotes, maxvotes, minrating, maxrating))
maxrating = int(maxrating*10)
minrating = int(minrating*10)
if maxvotes > 200000: maxvotes = ()
prefix = ''
if direction == 'descending': prefix = '-'
#if minvotes > 0: q = q.filter('imdbvotes >=', minvotes)
#if maxvotes < 300000: q = q.filter('imdbvotes <=', maxvotes)
#if minrating > 0: q = q.filter('imdbrating >=', minrating)
#if maxrating < 100: q = q.filter('imdbrating <=', minrating)
if order == 'age': q = q.order(prefix+'nzbdate')
if order == 'name': q = q.order(prefix+'rlsname')
if order == 'imdbrating': q = q.order(prefix+'imdbrating')
if order == 'imdbvotes': q = q.order(prefix+'imdbvotes')
if cursor: q = q.with_cursor(cursor)
#tm = {}
tm = []
i = []
count = 0
date = None
for m in q:
if count == 20: break
if not m.imdbrating: m.imdbrating = 0
if not m.imdbvotes: m.imdbvotes = 0
#How nice, a table scan :(
if not (minrating <= m.imdbrating <= maxrating and minvotes <= m.imdbvotes <= maxvotes):
continue
else:
count += 1
if m.imdbid == None:
m.imdbid = re.search('tt\d{7}', m.imdblink).group(0)
#m.put()
template_movie = {'type': 'movie'}
#template_movie['counter'] = count
template_movie['nzblink'] = m.nzblink
template_movie['rlsname'] = m.rlsname
template_movie['prettydate'] = util.pretty_date(m.nzbdate)
template_movie['imdblink'] = m.imdblink
template_movie['rtlink'] = 'http://www.rottentomatoes.com/alias?type=imdbid&s=%s' % m.imdbid[2:]
if m.imdbinfo:
template_movie['imdbinfo?'] = True
template_movie['rating'] = m.imdbinfo.rating / 10.0
template_movie['votes'] = m.imdbinfo.votes
template_movie['imdbinfo'] = m.imdbinfo
if m.imdbinfo.covers.count(1):
template_movie['cover'] = '/serve/%s' % m.imdbinfo.covers[0].blobkey.key()
i.append(template_movie)
else:
template_movie['imdbinfo?'] = False
if not date == m.nzbdate.date():
date = m.nzbdate.date()
tm.append({'d': date, 'day': date.strftime('%A, %d %B %Y'), 'type': 'date'})
#if not date in tm: tm[date] = {'d': date, 'day': date.strftime('%A, %d %B %Y'), 'movies': []}
tm.append(template_movie)
if count >= total_count: break
movies = (tm, i, q.cursor())
memcache.set(key, movies, namespace='movies')
return movies
示例4: home
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import all [as 别名]
def home():
q = Movie.all()
q.order("-votes")
return render_template('home.html', movies=q.run(limit=11), form=SearchForm(), image_path=settings.IMAGE_PATH, total=q.count(), offset=0)