예제 #1
0
    def __call__(self, *args, **kwargs):
        """Overide default Controller.__call__ behaviour"""

        # see if an image is being requested
        if len(args) == 1 and not bool(kwargs):
            images = zoom.store.store_of(Image)
            image = images.first(image_id=args[0]) or images.first(
                image_name=args[0])
            if image:
                item_id = image.image_id
                path = os.path.join(zoom.system.site.data_path, 'buckets')
                bucket = Bucket(path)
                return image_response(image.image_name, bucket.get(item_id))

        return zoom.Controller.__call__(self, *args, **kwargs)
예제 #2
0
 def get_image(self, *a, **k):
     """return one of the images from an ImagesField value"""
     item_id = k.get('item_id', None)
     path = os.path.join(system.site.data_path, 'buckets')
     bucket = Bucket(path)
     return image_response('house.png', bucket.get(item_id))
예제 #3
0
 def test_put_get(self):
     bucket = Bucket(self.path, self.ids.pop)
     item_id = bucket.put(b'some data')
     self.assertEqual(item_id, 'id_0000')
     self.assertEqual(bucket.get(item_id), b'some data')
예제 #4
0
 def show(self, key):
     path = os.path.join(zoom.system.site.data_path, 'buckets')
     bucket = Bucket(path)
     return image_response('house.png', bucket.get(key))
예제 #5
0
 def get_image(self, *a, **kwargs):  # pylint: disable=W0613
     """return one of the images"""
     item_id = kwargs.get('item_id', None)
     path = os.path.join(zoom.system.site.data_path, 'buckets')
     bucket = Bucket(path)
     return image_response('house.png', bucket.get(item_id))
예제 #6
0
 def get_image(self, *a, **k):
     """return one of the images from an ImagesField value"""
     item_id = k.get('item_id', None)
     path = os.path.join(system.site.data_path, 'buckets')
     bucket = Bucket(path)
     return image_response('house.png', bucket.get(item_id))
예제 #7
0
 def show(self, key):
     path = os.path.join(zoom.system.site.data_path, 'buckets')
     bucket = Bucket(path)
     image = bucket.get(key, False)
     if image:
         return image_response('image.png', image)