示例#1
0
    def get(self):
        groupid=self.request.get('groupid')
        group=ImgGroup.get_by_id(int(groupid))
        imglist=[]
        if group:
            imglist=Img.all().filter('group =',group.key().id()).order('-__key__').fetch(10)

        self.render('templates/piclist.html',{'group':group,'imglist':imglist})
示例#2
0
 def get(self):
     imgid=self.request.get("imgid")
     if not imgid:
         self.error(500)
         return
     image=Img.get_by_id(int(imgid))
     if image:
         self.response.headers['Content-Type'] = str(image.type)
         self.response.out.write(image.afile)
     else:
         self.error(505)
示例#3
0
    def post(self):
        if self.request.get('pic'):
            imgdata=self.request.get('pic')
            imgid=self.request.get("imgid") or ''
            logging.info('0'+str(imgid))
            img=Image(imgdata)
            group=self.request.get('group')

            pama=urllib.unquote(self.request.body)
            logging.info('1'+str(pama))
            #filename="11575.gif"
            s='filename="'
            n=pama.find(s)+len(s)
            nn=pama.find('"',n)
            pama=pama[n:nn]
#            pama=pama[pama.find('pic'):].split("&")
#            logging.info('2'+str(pama))
#
#            pama=pama[0].split('=')
#            logging.info('3'+str(pama))
#            pama=pama[1].split(',')[1]
#            logging.info('4'+str(pama))
#            pama=pama[pama.find("'")+1:pama.rfind(",")-1]
#            logging.info('5'+str(pama))
            type=pama.split('.')[1]
            logging.info('6'+str(pama))
            if type:
                type=type.lower()


            if img:
#                imgdata=img._image_data
                if img.width>350 and type!='gif':
                    imgdata=images.resize(imgdata,width=350)

                if imgid:
                    entity = Img.get_by_id(int(imgid))
                    if entity:
                        entity.ver+=1
                else:
                    entity = Img()
                entity.afile = db.Blob(imgdata)
                entity.group=int(group)
                if type=='gif':
                    entity.type='image/gif'
                elif type=='png':
                    entity.type='image/png'
                entity.put()
        self.redirect(str('/picadd'+'?groupid='+group))
示例#4
0
 def get(self):
     uname=self.request.get('UserName') or ''
     xml=None
     lib=None
     if uname:
         grouplist=[]
         u=User.get_by_key_name('u'+uname)
         if u:
             grouplist+=u.grouplist
         u=User.get_by_key_name('u000')
         if u:
             grouplist+=u.grouplist
         for group in grouplist:
             imglist=Img.all().filter('group =',group)
             grouptxt=ImgGroup.get_by_id(group).group
             xml,lib=infoallimgxmldic(imglist,xml,lib,group,grouptxt)
         if xml:
             self.response.out.write(xml.toxml('utf-8'))
示例#5
0
    def get(self):
        imgid=self.request.get("image_id")
        if imgid:
            imgidlist=imgid.split('_')
            if (len(imgidlist)==3 or len(imgidlist)==4) and imgidlist[-1] in ['11','12','31','41']:
                if imgidlist[0] in ['min','daily','weekly','monthly']:
                    self.response.headers['Content-Type'] = "text/html"
                    if imgidlist[-1]=='41':
#                        self.response.out.write('http://image.sinajs.cn/newchart/usstock/%s/%s.gif'%(imgidlist[0],imgidlist[-2]))
                        if 'min'==imgidlist[0]:
                            self.response.out.write('http://image.sinajs.cn/newchart/v5/usstock/wap/min_daily/310/%s.gif?r=%s'%(imgidlist[-2],datetime.datetime.now().strftime('%Y%m%d%H%M')))
                        if 'daily'==imgidlist[0]:
                            self.response.out.write('http://image.sinajs.cn/newchart/v5/usstock/wap/min_week/310/%s.gif?r=%s'%(imgidlist[-2],datetime.datetime.now().strftime('%Y%m%d%H%M')))
                        return
                    elif imgidlist[-1]=='31':
#                        self.response.out.write('http://image.sinajs.cn/newchart/hk_stock/%s/%s.gif'%(imgidlist[0],imgidlist[-2][2:]))
                        if 'min'==imgidlist[0]:
                            self.response.out.write('http://image.sinajs.cn/newchart/hk_stock/wap_min5/%s.gif?r=%s'%(imgidlist[-2][2:],datetime.datetime.now().strftime('%Y%m%d%H%M')))
                        if 'daily'==imgidlist[0]:
                            self.response.out.write('http://image.sinajs.cn/newchart/hk_stock/daily_wap5/%s.gif?r=%s'%(imgidlist[-2][2:],datetime.datetime.now().strftime('%Y%m%d%H%M')))

                        return
                    elif imgidlist[-1] in ['11','12']:
#                        self.response.out.write('http://image.sinajs.cn/newchart/%s/n/%s.gif'%(imgidlist[0],imgidlist[-2]))
                        if 'min'==imgidlist[0]:
                            self.response.out.write('http://image.sinajs.cn/newchart/wap/cn_min_other/min_wap/3g/big/%s.gif?r=%s'%(imgidlist[-2],datetime.datetime.now().strftime('%Y%m%d%H%M')))
                        if 'daily'==imgidlist[0]:
                            self.response.out.write('http://image.sinajs.cn/newchart/wap/cn_kline/daily_wap/3g/big/%s.gif?r=%s'%(imgidlist[-2],datetime.datetime.now().strftime('%Y%m%d%H%M')))
                        return
                    else:
                        self.error(500)
                        return
        if not imgid or imgid[0]=='0':
            self.error(500)
            return
        image=Img.get_by_id(int(imgid))
        if image:
            self.response.headers['Content-Type'] = str(image.type)
            self.response.out.write(image.afile)
        else:
            self.error(505)