本文整理汇总了Python中models.Photo.get方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.get方法的具体用法?Python Photo.get怎么用?Python Photo.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_current_photo
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def remove_current_photo(self, album_id='', photo_id=''):
if request.method == 'GET':
if photo_id:
try:
photo = Photo.get(id=photo_id)
photo.delete_instance()
flash(u"Фотографія %s успішно видалина." % photo.title)
except DoesNotExist, e:
print '%s' % e
示例2: remove_photo
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def remove_photo(self, album_id=''):
if request.method == 'POST':
form = request.form
for v in form.itervalues():
try:
photo = Photo.get(id=v)
photo.delete_instance()
except DoesNotExist, e:
print '%s' % e
示例3: photo
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def photo(request, owner, nb):
try:
photo = Photo.get(owner, nb)
owner = User.get(owner)
return render(request, 'photo.html', {
'owner': owner,
'photo': photo
})
except (Photo.DoesNotExist, User.DoesNotExist):
return HttpResponseRedirect('/')
示例4: prepare_photo_files
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def prepare_photo_files(owner, nb):
storage = Client(domain = settings.MOGILEFS_DOMAIN,
trackers = settings.MOGILEFS_TRACKERS)
#im = Image.open(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s.jpg' % id))
f = storage.read_file(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s,%s.jpg' % (owner, nb)))
im = Image.open(f)
im.thumbnail((160, 160), Image.ANTIALIAS)
tn = storage.new_file(path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb)))
im.save(tn, 'JPEG')
#sleep(20)
photo = Photo.get(owner, nb)
photo.ready()
示例5: form
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def form(self):
if self.request.args.get('photo'):
key=db.Key(self.request.args['photo'])
photo=Photo.get(key)
form_data=MultiDict({
'name':photo.name,
'existing_photo':key,
'email':photo.email,
'phone':photo.phone,
}.iteritems())
return(AddPhotoForm(form_data))
else:
return AddPhotoForm(self.request.form)
示例6: get
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def get(self, photo_id):
photo = Photo.get(photo_id)
if photo:
if self.request.get('type'):
force_crop = self.request.get('crop', False)
if force_crop: force_crop = True
cropped, img = crop_image(photo.file, self.request.get('type'),
strict=force_crop)
if img:
self.response.headers['Content-Type'] = 'image/jpg'
self.response.out.write(img)
else:
self.response.out.write('No image')
self.response.headers['Content-Type'] = str('image/%s' % photo.extension)
self.response.out.write(photo.file)
else:
self.response.out.write('No image')
示例7: parse_item
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def parse_item(self,item):
name = item.xpath("div[@class='user-info']/h3/a")[0].text
twitter = item.xpath("div[@class='user-info']/h3/span/a")[0].text
avators = item.xpath("div[@class='photo-link-outer']/a/img//@src")
with db_session:
girl = Girl.get(twitter=twitter)
if girl is None:
girl = Girl(name=name,twitter=twitter)
else:
girl.name = name
commit()
for avator in avators:
photo = Photo.get(link=avator)
if photo is None:
try:
local = crawl_photo(avator)
photo = Photo(uid=girl.id,link=avator,local=local)
commit()
except requests.exceptions.ConnectionError:
pass
示例8: post
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import get [as 别名]
def post(self, photo_id):
if self.request.get('action') == 'delete':
photo = Photo.get(photo_id)
if photo:
photo.delete()
self.response.out.write('ok')