本文整理汇总了Python中models.Photo.title方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.title方法的具体用法?Python Photo.title怎么用?Python Photo.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.title方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_photo
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import title [as 别名]
def add_photo(self, album_id=''):
if request.method == 'POST':
album = Album.get(id=album_id)
photo = Photo()
photo.album = album
file = request.files['files']
photo_title, size, photo_path, photo_url, thumb_url, thumb_path = self.gal_man.add_photo(album, file)
result = []
result.append({
'name':photo_title,
'size':size,
'url':photo_url,
'thumbnail_url':thumb_path,
"delete_type":"POST",
})
photo.title = photo_title
photo.photo_path = photo_path
photo.thumb_path = thumb_path
photo.photo_url = photo_url
photo.thumb_url = thumb_url
photo.size = size
photo.save()
return json.dumps(result)
else:
return 'response'
示例2: upload
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import title [as 别名]
def upload(req):
if req.method == "POST":
pf = PhotoForm(req.POST, req.FILES)
if pf.is_valid():
# 获取表单信息
title = pf.cleaned_data['title']
image = pf.cleaned_data['image']
# 写入数据库
photo = Photo()
uid = req.session['user_id']
iid = 1#req.session['item_id']
photo.title = title
photo.image = image
photo.uid = uid
photo.iid = iid
photo.save()
return HttpResponseRedirect('/online/photolist/')
else:
pf = PhotoForm()
return render_to_response('upload.html', {'pf': pf}, context_instance=RequestContext(req))
示例3: writeToDB
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import title [as 别名]
def writeToDB(photo, nickname):
newPhoto = Photo()
newPhoto.owner = nickname
newPhoto.photoid = photo.gphoto_id.text
newPhoto.thumbnail = photo.media.thumbnail[2].url
newPhoto.title = photo.title.text
try:
newPhoto.time = datetime.datetime.fromtimestamp(float(photo.exif.time.text) / 1e3)
except:
pass
try:
newPhoto.exposure = photo.exif.exposure.text
except:
pass
try:
newPhoto.focallength = photo.exif.focallength.text
except:
pass
try:
newPhoto.make = photo.exif.make.text
except:
pass
try:
newPhoto.fstop = photo.exif.fstop.text
except:
pass
try:
newPhoto.model = photo.exif.model.text
except:
pass
try:
newPhoto.flash = photo.exif.flash.text
except:
pass
try:
newPhoto.iso = photo.exif.iso.text
except:
pass
# Add to db after retrieved
newPhoto.put()
示例4: post
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import title [as 别名]
def post(self, id=None):
if id:
photo = Photo.gql("WHERE id = :1", id).get()
else:
photo = Photo(content_type="image/jpg")
date_posted = utils.strptime_for_edit(self.request.get('date_posted'))
photo.title = self.request.get('title')
photo.id = get_photo_id(date_posted, self.request.get('slug'))
photo.location = self.request.get('location')
location_slug = utils.slug(photo.location)
location = db.Query(PhotoLocation).filter("id = ", location_slug).get()
if not location:
location = PhotoLocation(id=location_slug, name=photo.location)
location.put()
photo.location_ref = location
photo.categories = self.request.get('categories')
photo.categories_ref = []
for category_name in photo.categories.split(","):
category_name = category_name.strip()
category_slug = utils.slug(category_name)
category = db.Query(PhotoCategory).filter("id = ", category_slug).get()
if not category:
category = PhotoCategory(id=category_slug, name=category_name)
category.put()
photo.categories_ref.append(category.key())
photo.description = self.request.get('description')
photo.date_posted = date_posted
if self.request.get('file'):
photo.file = db.Blob(self.request.get('file'))
photo.thumbnail = images.resize(photo.file, 128, 128)
photo.put()
self.redirect(photo.get_url())