Ejemplo n.º 1
0
    def _get(self):
        upload_url = blobstore.create_upload_url('/image/submit')
        page = self.request.get("page")
        try:
            page = int(page) - 1
        except:
            page = 0

        query = ImageAsset.all().order('-created_at')
        images = query.fetch(1000)
        if (self.PAGESIZE * page)/1000 > 0:
            cursor_iterations = (self.PAGESIZE * page)/1000
            for i in range(0, cursor_iterations):
                logging.info("Iterating though images %d/%d" % (i,cursor_iterations))
                cursor = query.cursor()
                query.with_cursor()
                images = query.fetch(1000)
        paginator = ObjectPaginator(images, self.PAGESIZE)
        #if page>=paginator.pages:
        #    page = paginator.pages - 1
        #if page < 0:
        #    page = 0
        self.template_values = {
              "images" : paginator.get_page(page),
              "pages" : range(page+1,page+paginator.pages+1),
              "page" : page+1,
              "upload_url" : upload_url
        }
        self.page_display(self,"templates/gallery.html")
Ejemplo n.º 2
0
 def get(self):
     query = ImageAsset.all(keys_only=True)
     i = 0
     while True:
         result = query.fetch(1000)
         i = i + len(result)
         if len(result) < 1000:
             break
         cursor = query.cursor()
         query.with_cursor(cursor)
     self.response.out.write(simplejson.dumps({ 'count': i }))
Ejemplo n.º 3
0
 def get(self):
     upload_url = blobstore.create_upload_url('/image/submit')
     page = self.request.get("page")
     try:
         page = int(page) - 1
     except:
         page = 0
     images = ImageAsset.all().order('-created_at')
     paginator = ObjectPaginator(images, self.PAGESIZE)
     if page>=paginator.pages:
         page = paginator.pages - 1
     if page < 0:
         page = 0
     self.template_values = {
           "images" : paginator.get_page(page),
           "pages" : range(1,paginator.pages+1),
           "page" : page+1,
           "upload_url" : upload_url
     }
     self.page_display(self,"templates/gallery.html")
Ejemplo n.º 4
0
# /opt/google_appengine/remote_api_shell.py -s image-hulk-stage.appspot.com image-hulk-stage
import sys
sys.path.append('/image_hulk')
from bb.hulk.models import ImageAsset
from google.appengine.ext import blobstore
query = ImageAsset.all().order('created_at')
images = query.fetch(1000)
while len(images) > 0:
    for image in images:
        print "deleting image %s" % image.handle
        blobstore.delete(image.blob_key.key())
        image.delete()
    cursor = query.cursor()
    query.with_cursor()
    images = query.fetch(1000)