本文整理汇总了Python中models.Photo.url方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.url方法的具体用法?Python Photo.url怎么用?Python Photo.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_conversation
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import url [as 别名]
def create_conversation(user_id, conversation):
conversation_type = conversation.get('conversation_type')
conversationees_list = conversation.get('conversationees_list')
conversationees_list = list(set(conversation.get('conversationees_list',[])))
if conversation_type == conversations_config.get('CONVERSATION_DIRECT_TYPE') and len(conversationees_list) != 2:
raise InvalidConversationException('Direct conversations should have 2 conversationees')
ct = ConversationType.get(ConversationType.name == conversation_type)
c = Conversation()
c.conversation_type = ct
p_url = conversation.get('picture','')
picture = None
if p_url:
picture = Photo()
picture.url = p_url
name = conversation.get('name','')
cps = []
myself = None
for index, conversationee in enumerate(conversationees_list):
n = None
p = None
if conversation_type == 'group':
n = name
p = picture
else:
data = get_user_data(index, conversationees_list)
n = data[0]
p = data[1]
cp = ConversationParty()
cp.conversation = c
cp.name = n
cp.user = User.get(User.id==conversationee)
cp.picture = p
cps.append(cp)
if conversationee == user_id:
myself = cp
with database.transaction():
c.save()
if picture:
picture.save()
for cp in cps:
cp.save()
return __jsonify_one_conversation(myself)
示例2: img_save
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import url [as 别名]
def img_save(self):
"""
Tests that we can save a Photo.
"""
# self.failUnlessEqual(1 + 1, 2)
from PIL import Image
from models import Photo
im = Image.open('P1020515.JPG')
photo = Photo()
photo.img=im
photo.url='http://go00gle.com'
photo.save()
self.failUnlessEqual(im,photo.img)
self.failUnlessEqual(photo.url, 'http://google.com')
示例3: albumpage
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import url [as 别名]
def albumpage(request, albumid, pageno):
pageno = int(pageno)
user = Helpers.getUser(request)
album = get_object_or_404(Album, id=albumid, owner=user)
context = {"album": album}
# Fetch information about the requested page
context["pageno"] = pageno
albumpage = get_object_or_404(AlbumPage, album=albumid, pageno=pageno)
context["albumpage"] = albumpage
if pageno > 1:
context["prevpageno"] = int(pageno) - 1
if pageno < album.pages.count():
context["nextpageno"] = int(pageno) + 1
photosdict = Helpers.createPhotoDictionary(albumpage)
context["photos"] = photosdict
# If we returned from the search/basket page, there's a caption in the URL. Extract that
# There is a maximum of 4 photos per page in any layout
if request.method == 'GET':
if "search-result-url" in request.GET:
photono = request.GET["photono"] if "photono" in request.GET else None
if photono in photosdict:
photo = photosdict[photono]
else:
photo = Photo(albumpage_id=albumpage.id, photono=photono)
photosdict[photono] = photo
photo.url = request.GET["search-result-url"]
photo.unsaved = True
context["unsaved"] = True
# If this was an edit, update the objects with the new values
if request.method == 'POST':
# There is a maximum of 4 photos per page in any layout
for photono in range(1, 5):
newcaption = request.POST.get("photo-%d-caption" % photono, None)
newurl = request.POST.get("photo-%d-url" % photono, None)
if newcaption or newurl:
if photono in photosdict:
photo = photosdict[photono]
else:
photo = Photo(albumpage_id=albumpage.id, photono=photono)
photosdict[photono] = photo
photo.caption = newcaption
photo.url = newurl
photo.save()
album.cover = photo
album.save()
# Render response.
# First choose the template to use for this page's layout.
context["layouttemplate"] = 'albumpage-layout-%d.html' % albumpage.layout
# for convenience, editmode is passed to the template as a string that can
# be appended to URLs
if "edit" in request.GET:
context["editmode"] = "?edit=true"
return render_to_response('albumpage.html', context, context_instance=RequestContext(request))