本文整理汇总了Python中models.Photo.all方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.all方法的具体用法?Python Photo.all怎么用?Python Photo.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def __init__(self):
t = datetime.datetime.now() - datetime.timedelta(hours=4)
s = Subject().get_current().key().id()
for img in (
Photo.all().filter("subject_id =", s).filter("is_blocked =", False).filter("date_updated <", t).fetch(10)
):
self.fetch_img(img.instagram_id)
示例2: refresh_gallery
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
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')
示例3: list_files
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def list_files():
logger.debug('list files')
photos = Photo.all()
logger.debug(photos)
context = {'photos': photos}
template = j2env.get_template('templates/list.html')
return template.render(context)
示例4: show_public_photo
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def show_public_photo(request, key):
extra_context = {
'object_list': Thumbnail.all().order('-photo_date_added'),
'viewed_username': 'public',
}
return object_detail(request, Photo.all(), key,
template_name='photo/public-show.html',
template_object_name='photo',
extra_context=extra_context)
示例5: get
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def get(self, *args, **kwargs):
last_50 = Photo.all().filter('is_active =', True).filter('is_user_active =', True).filter('is_blocked =',
False).order(
'-date_added').fetch(limit=20)
i = 0
last_50 = [p for p in last_50]
photos = []
for x in xrange(0, len(last_50) / 2):
photos.append([last_50[i], last_50[i + 1]])
i += 2
self.render(os.path.join(os.path.dirname(__file__), 'templates/index.html'), photos=photos, submitted=False)
示例6: get
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def get(self, subject_id, username):
photos = []
for photo in (
Photo.all()
.filter("user =", username)
.filter("subject_id =", int(subject_id))
.filter("is_active =", True)
.filter("is_user_active =", True)
.filter("is_blocked =", False)
.order("-total_score")
):
photos.append(photo.to_dict())
self.response.out.write(json.dumps({"photos": photos}))
示例7: users_page
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def users_page(request, username):
viewed_user = User.get_user_by_username_or_404(username)
photo = None
fetched_photo_list = Photo.all().filter('user', viewed_user).order('-date_added').fetch(1)
if fetched_photo_list:
photo = fetched_photo_list[0]
extra_context = {
'viewed_user': viewed_user,
'photo': photo,
'viewed_username': username
}
return object_list(request,
queryset=Thumbnail.all().filter('photo_user', viewed_user).order('-photo_date_added'),
template_name='photo/show.html',
extra_context=extra_context
)
示例8: get
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import all [as 别名]
def get(self):
photo_list = Photo.all().order('-updated_at')
template_vars = { 'object_list': photo_list }
self.render_response('photo/photo_list.html', template_vars)