• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Images类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Images的典型用法代码示例。如果您正苦于以下问题:Python Images类的具体用法?Python Images怎么用?Python Images使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Images类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: addImage

def addImage(mime,description,bf,name):
    'Add Image'
    image=Images(mime=mime,description=description,bf=bf,name=name)
    image.size=len(image.bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    image.put() 
    return image
开发者ID:msallk,项目名称:photocollector,代码行数:7,代码来源:methods.py


示例2: delete

    def delete(self, id):
        image = Images.first(id=id)
        msg = "The image could not be deleted."
        if image and Images.delete(image):
            msg = "Image deleted"
        cherrypy.session['flash'] = msg

        raise cherrypy.HTTPRedirect('/images')
开发者ID:masom,项目名称:Puck,代码行数:8,代码来源:images.py


示例3: addImage

def addImage(name, mime,description,tag,bf):
    'Add Image'
    image=Images(name=name, mime=mime,description=description,tag=tag.split(','), bf=bf)
    image.size=len(image.bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    image.put()
    AddTags(image.tag)
    return image
开发者ID:studyzy,项目名称:gae_image,代码行数:8,代码来源:methods.py


示例4: AddImageByUrl

def AddImageByUrl(url,fileName,tag):
    result = urlfetch.fetch(url)
    if result.status_code == 200:
        name = fileName
        mtype = result.headers.get('Content-Type', '')
        bits = result.content
        gf=GaeFile()
        gf.open(name,mtype);
        gf.write(bits)
        id=gf.close()
        
        image=Images(description="/media/?key="+str(id))
        image.mime=result.headers.get('Content-Type', '')
        image.filetype=image.mime
        # if image.mime.find('image')==-1:
            # return None
        image.size=len(bits)
        image.width=-1;
        image.height=-1;
        # image.name=fileName
        # image.filetype,image.width,image.height=getImageInfo(image.bf)
        image.tag=tag.split(',')
        image.put()
        AddTags(image.tag)
        return image
    else:
        return None
开发者ID:studyzy,项目名称:gae_image,代码行数:27,代码来源:methods.py


示例5: addImage

def addImage(mime,description,bf):
    'Add Image'
    image=Images(mime=mime,description=description)
    image.size=len(image.bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    image.put()
    
    imageblob = ImageBlob(image=image, bf=bf)
    imageblob.put()
    
    prependToRSS([image])
    
    return image
开发者ID:Letractively,项目名称:code-of-ldmiao,代码行数:13,代码来源:methods.py


示例6: get

 def get(self):
     collector = CloudFetch.CloudFetch()     
     urllist = collector.getUrlList()
     #url = 'http://www.technobuffalo.com/wp-content/uploads/2012/12/Google-Apps.jpeg'
     #urllist = urllist.append(url)
     images = Images.all()
     for url in urllist:
         bf = urllib.urlopen(url).read()
         #bf=self.request.get("file")
         if not bf:
             return self.redirect('/')
         #name=self.request.body_file.vars['file'].filename
         #mime = self.request.body_file.vars['file'].headers['content-type']
         #if mime.find('image')==-1:
         #     return self.redirect('/admin/upload/')
         #description=self.request.get("description")
         mime = 'image'
         description = 'Fetched From Cloud'
         name = url.split('/')[len(url.split('/'))-1]
         #DETECT DUPLICATE
         flag = False;
         for i in images:
             if(i.name == name):
                 flag = True
                 break
         if(flag == True):
             continue
         image=methods.addImage( mime, description, bf, name)
     self.redirect('/')
开发者ID:msallk,项目名称:photocollector,代码行数:29,代码来源:admin.py


示例7: delImageByid

def delImageByid(id):
    image=Images.get_by_id(int(id))
    if image:
        imageblob = db.GqlQuery("SELECT * FROM ImageBlob WHERE image = :1", image).get()
        if imageblob:
            imageblob.delete()
        image.delete()
开发者ID:Letractively,项目名称:code-of-ldmiao,代码行数:7,代码来源:methods.py


示例8: delImage

def delImage(key):
    image=Images.get(key)
    if image:
        imageblob = db.GqlQuery("SELECT * FROM ImageBlob WHERE image = :1", image).get()
        if imageblob:
            imageblob.delete()
        image.delete()
开发者ID:Letractively,项目名称:code-of-ldmiao,代码行数:7,代码来源:methods.py


示例9: index

 def index(self):
     user_id = cherrypy.session.get('user.id')
     vms = VirtualMachines.find(user_id=user_id)
     env = dict(
         virtual_machines=vms,
         images=Images.all(),
         instance_types=InstanceTypes.all()
     )
     return self.render("virtual_machines/index.html", self.crumbs, **env)
开发者ID:masom,项目名称:Puck,代码行数:9,代码来源:virtual_machines.py


示例10: gallery

def gallery(request,imagename=None):
	print imagename
	if request.method == 'POST':
		title = request.POST['pname']
		img_data = request.POST['pdata']
		p = Images(title = title, img_data = img_data)
		p.save()
	if 	request.method == 'GET':
		image = Images.objects.filter(title = imagename)
		for i in image:
			data = i.img_data
		print json.dumps(data)
		t = get_template('paint.html')
		html = t.render(Context({}))
		if data:
			html="""<script>var data=JSON.parse(' """+data+""" ');</script>"""+html		
		else:
			html="""<script>alert("Image not found")</script>"""+html
		return HttpResponse(html)
开发者ID:josejibin,项目名称:Paint-App-Using-Django,代码行数:19,代码来源:views.py


示例11: add

    def add(self, **post):
        image = Images.new(name="", backend_id="", description="")

        if post:
            fields = ['name', 'backend_id', 'description']
            data = self._get_data('image', fields, post)
            self._set_data(image, data)

            if image.validates() and Images.add(image):
                cherrypy.session['flash'] = "Image added"
                raise cherrypy.HTTPRedirect('/images')
            cherrypy.session['flash'] = 'Invalid data'

        backend_images = Images.get_backend_images()
        env = dict(
            image = image,
            backend_images = backend_images
        )
        return self.render("/images/add.html", crumbs=self.crumbs, **env)
开发者ID:masom,项目名称:Puck,代码行数:19,代码来源:images.py


示例12: edit

    def edit(self, id, **post):
        image = Images.first(id=id)

        if not image:
            cherrypy.session['flash'] = "404 Image Not Found"
            raise cherrypy.HTTPRedirect('/images')

        if post:
            fields = ['name', 'backend_id', 'description']
            data = self._get_data('image', fields, post)
            if image.update(data, fields):
                cherrypy.session['flash'] = "Image successfully updated."
                raise cherrypy.HTTPRedirect('/images')

            cherrypy.session['flash'] = 'Invalid data'

        backend_images = Images.get_backend_images()
        env=dict(image = image, backend_images=backend_images)
        return self.render("/images/edit.html", crumbs=self.crumbs, **env)
开发者ID:masom,项目名称:Puck,代码行数:19,代码来源:images.py


示例13: add_image

def add_image(request):
    form = ImageForm()
    if request.POST:
        form = ImageForm(request.POST, request.FILES)
        if form.is_valid():
            image = request.FILES['image_file']
            comment = form.cleaned_data['comment']
            format = image.name.split('.')[-1]
            p = Images(comment = comment, name = '',
            useragent = request.META['HTTP_USER_AGENT'],
            ip = request.META['REMOTE_ADDR'], views = 0 ,views_last_hour = 0,
            md5 = 0, format = format)
            p.save()
            save_image(image, p.id)
            return HttpResponseRedirect('/%s' % to_62(p.id))
        else:
            form = ImageForm()
            return render_to_response("forms/add_image.html", {'form': form})
    else:
        return render_to_response("forms/add_image.html", {'form': form})
开发者ID:denplis,项目名称:Picco,代码行数:20,代码来源:views.py


示例14: running

    def running(self):
        creds = cherrypy.session.get('credentials')
        vms = VirtualMachines.all()
        images = Images.all()
        instances = VirtualMachines.get_instances(creds)
        env = dict(
            virtual_machines=vms,
            instances=instances,
            images=images,
        )

        return self.render("virtual_machines/running.html", self.crumbs,**env)
开发者ID:masom,项目名称:Puck,代码行数:12,代码来源:virtual_machines.py


示例15: add_image

def add_image(request):
    #last_image_id = Images.objects.order_by('-id')[0].id else last_image_id = 0
    form = ImageForm()
    if request.POST:
        form = ImageForm(request.POST, request.FILES)
        if form.is_valid():
            image = request.FILES['image_file']
            
            save_image(image)
            
            #thumb_image = thumbnail(image)
            #save_image(thumb_image)
            p = Images(comment=request.POST['comment'], name = file.name,
            useragent=request.META['HTTP_USER_AGENT'],
            ip=request.META['REMOTE_ADDR'], views=0, md5=0 )
            p.save()
            return HttpResponse(image.name)
            #return render_to_response("forms/add_image.html", {'form': form})
        else:
            return render_to_response("forms/add_image.html", {'form': form})
    else:
        return render_to_response("forms/add_image.html", {'form': form})
开发者ID:denplis,项目名称:Picco,代码行数:22,代码来源:views.py


示例16: addImage2

def addImage2(bf):
    image=Images(bf=bf)
    image.size=len(bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    if not image.filetype:return None
    image.mime=image.filetype
    image.put()
    return image
开发者ID:studyzy,项目名称:gae_image,代码行数:8,代码来源:methods.py


示例17: AddImageByUrlBak

def AddImageByUrlBak(url,fileName,tag):
    result = urlfetch.fetch(url)
    if result.status_code == 200:
        image=Images(description=url,bf=result.content)
        image.mime=result.headers.get('Content-Type', '')
        if image.mime.find('image')==-1:
            return None
        image.size=len(image.bf)
        image.name=fileName
        image.filetype,image.width,image.height=getImageInfo(image.bf)
        image.tag=tag.split(',')
        image.put()
        AddTags(image.tag)
        return image
    else:
        return None
开发者ID:studyzy,项目名称:gae_image,代码行数:16,代码来源:methods.py


示例18: xmlparse

def xmlparse():
    #pagecode = urllib.urlopen("http://www.esmadrid.com/opendata/alojamientos_v1_es.xml")
    pagecode = urllib.urlopen("http://cursosweb.github.io/etc/alojamientos_es.xml")
    xmlsheet = pagecode.read()
    noticias=xmlsheet.split("<service ")
    for noticia in noticias[1:-1]:
        url = noticia.split("<web>")[1].split("</web>")[0]
        try:
            alojamiento = Alojamientos.objects.get(url=url)
        except Alojamientos.DoesNotExist:
            name = noticia.split("<name><![CDATA[")[1].split("]]></name>")[0]
            address = noticia.split("<address>")[1].split("</address>")[0]
            zipcode = noticia.split("<zipcode>")[1].split("</zipcode>")[0]
            country = noticia.split("<country>")[1].split("</country>")[0]
            latitude = noticia.split("<latitude>")[1].split("</latitude>")[0]
            longitude = noticia.split("<longitude>")[1].split("</longitude>")[0]
            city = noticia.split("<subAdministrativeArea>")[1].split("</subAdministrativeArea>")[0]
            alojamiento = Alojamientos(name=name, url=url, address=address, zipcode=zipcode, country=country, latitude=latitude, longitude=longitude, city=city)
            alojamiento.save()
            images = noticia.split('<url>')
            for image in images[1:6]:
                image_url = image.split('</url>')[0]
                image = Images(url=image_url, alojamiento=alojamiento)
                image.save()
开发者ID:rodrigobersan,项目名称:X-Serv-Practica-Hoteles,代码行数:24,代码来源:views.py


示例19: addImage

def addImage(title,bf,referer):
    'Add Image'
    image=Images(description=title,bf=bf,referer=referer)
    image.size=len(image.bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    if not image.filetype:return None
    image.mime=image.filetype
    
    image.put()
    return image
开发者ID:fireyy,项目名称:pyasaph,代码行数:10,代码来源:methods.py


示例20: addImage2

def addImage2(bf):
    image=Images()
    image.size=len(bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    if not image.filetype:return None
    image.mime=image.filetype
    image.put()
    
    imageblob = ImageBlob(image=image, bf=bf)
    imageblob.put()
    
    prependToRSS([image])
    
    return image
开发者ID:Letractively,项目名称:code-of-ldmiao,代码行数:14,代码来源:methods.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Issue类代码示例发布时间:2022-05-27
下一篇:
Python models.Image类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap