当前位置: 首页>>代码示例>>Python>>正文


Python Photo.url方法代码示例

本文整理汇总了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)
开发者ID:FelipePiacsek,项目名称:chat_angular,代码行数:59,代码来源:conversations.py

示例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')
开发者ID:eknuth,项目名称:photomapapp,代码行数:18,代码来源:tests.py

示例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))
开发者ID:joooda,项目名称:omatesti,代码行数:70,代码来源:views.py


注:本文中的models.Photo.url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。