Exemple #1
0
    def get(self):
        cachekey = "V9Gallery_CACHE"
        data = memcache.get(cachekey)
        if not data:
            logging.info('%s cache is not found' % cachekey)
            albums = methods.GetAllAlbums()
            _albums = []
            for a in albums:
                _value = {'album': a, 'photos': None}
                photos = a.Photos(1, 1000)
                _photos = []
                for photo in photos:
                    photo.url = '/'.join(photo.imgurl.split('/')[-2:])
                    _photos.append(photo)

                _albums.append({'album': a, 'photos': _photos})
            template_value = {'albums': _albums}
            path = os.path.join(os.path.dirname(__file__),
                                'views/' + version + '/gallery.xml')
            template_value["config"] = model.settings
            data = template.render(path, template_value)
            memcache.set(cachekey, data, 3600)

        expires_date = datetime.datetime.utcnow() + datetime.timedelta(days=7)
        expires_str = expires_date.strftime("%d %b %Y %H:%M:%S GMT")
        self.response.headers.add_header("Expires", expires_str)
        self.response.headers['Cache-Control'] = 'max-age=120, must-revalidate'
        self.response.headers['Content-type'] = 'application/xml'
        self.response.out.write(data)
Exemple #2
0
 def get(self, id):
     album = methods.GetAlbum(id)
     photos = album.Photos(page=1, pagesize=1000)
     data = {
         'albums': methods.GetAllAlbums(),
         'photos': photos,
         'albumid': id,
         'settings': model.settings
     }
     self.render('views/admin/photos.html', data)
Exemple #3
0
    def get(self, page):

        if self.request.get('flush') is not None:
            memcache.flush_all()
        albums = methods.GetAllAlbums()
        template_value = {
            "albums": albums[:24],
            "isadmin": self.is_admin(),
            "config": model.settings,
            'usage': self.usage
        }

        self.render('index.html', template_value)
Exemple #4
0
 def get(self):
     self.render('views/admin/index.html',
                 {'albums': methods.GetAllAlbums()})