Ejemplo n.º 1
0
 def get(self):
     action = self.request.get('action')
     
     output = "0"
     if action=='clear':
         images=methods.getImages(count=50)
         if(len(images)>0):
             output = str(len(images))
         db.delete(images)
         self.response.out.write(output)
     elif action=='getrss':
         rss_template = methods.get_rss_template()
         rss = memcache.get("rss_content")
         if rss:
             #self.response.headers['Content-Type'] = "application/rss+xml"
             self.response.headers['Content-Type'] = "text/xml"
             self.response.out.write(rss_template%(rss))
         else:
             self.response.out.write('not right!')
     elif action=='regeneraterss':
         generate = memcache.get("rss_generate")
         rss = memcache.get("rss_content")
         lastImage_date = memcache.get("rss_lastImage_date")
         
         if generate=='create':
             memcache.delete('rss_content')
             memcache.delete('rss_lastImage_date')
             memcache.set("rss_generate", 'not_create')
             logging.info('set rss_generate to not_create')
             lastImage_date = None
             rss = ''
             
         if rss and lastImage_date:
             pass
         else:
             lastImage_date = None
             rss = ''
         
         images=methods.getImagesBefore(count=50, lastImage_date=lastImage_date)
         if(len(images)>0):
             rss += methods.generateRSSItems(images)
             length = len(images)
             lastImage_date = images[length-1].created_at
             output = str(length)
             memcache.set('rss_content', rss)
             memcache.set('rss_lastImage_date', lastImage_date)
             
         else:
             methods.persistRSS()
             memcache.set("rss_generate", 'create')
             logging.info('set rss_generate to create')
         
         self.response.out.write(output)
     else:
         self.render('views/admin.html', {})
Ejemplo n.º 2
0
 def get(self):
     count = self.request.get("count")
     if count:
         count = int(count)
     else:
         count = 30
     index = 0
     images = methods.getImages(count=count, offset=index)
     template_value = {"images": images, "userid": "userid"}
     self.response.headers["Content-Type"] = "text/xml"
     self.render("views/pictures.xml", template_value)
Ejemplo n.º 3
0
    def get(self):
        rss = methods.getRSSItemsString()
        if rss:
            pass
        else:
            images = methods.getImages(count=300)
            rss = methods.generateRSSItems(images)

        self.response.headers["Content-Type"] = "application/rss+xml"
        # self.response.headers['Content-Type'] = "text/xml"
        rss_template = methods.get_rss_template()
        self.response.out.write(rss_template % (rss))
Ejemplo n.º 4
0
    def get(self):
        # page = self.request.get('page')
        # index=0 if page=="" or page==None else 100*int(page)

        page = memcache.get("flash_page_key")
        if page:
            page = int(page)
        else:
            page = 0

        logging.info(page)
        index = 300 * int(page)

        images = methods.getImages(count=300, offset=index)
        template_value = {"images": images}
        self.response.headers["Content-Type"] = "text/xml"
        self.render("views/gallery.xml", template_value)
Ejemplo n.º 5
0
 def get(self):
     images = methods.getImages()
     template_value = {"images": images}
     self.response.headers["Content-Type"] = "text/xml"
     self.render("views/xml.html", template_value)
Ejemplo n.º 6
0
 def get(self):
     images = methods.getImages()
     template_value = {"images": images}
     self.render("views/slide.html", template_value)