class ShowCurrentEdit(BrowserView):
    """
    Just a browser view to get latest edited image
    """
    def __init__(self, context, request):
        super(BrowserView, self).__init__(context, request)
        self.imageeditor = IImageEditorAdapter(context)
        self.imageeditor.set_field(request.get('field', ''))

    def __call__(self):
        resp = self.request.response
        imagedata = self.imageeditor.get_current_image_data()
        resp.setHeader('Content-Type', 'image/jpeg')
        resp.setHeader('Content-Length', len(imagedata))
        resp.setHeader('Last-Modified',
            strftime('%a, %d %b %Y %H:%M:%S +0000', gmtime()))
        resp.write(imagedata)
        return ''
class ShowCurrentEdit(BrowserView):
    """
    Just a browser view to get latest edited image
    """
    def __init__(self, context, request):
        super(BrowserView, self).__init__(context, request)
        self.imageeditor = IImageEditorAdapter(context)
        self.imageeditor.set_field(request.get('field', ''))

    def __call__(self):
        resp = self.request.response
        imagedata = self.imageeditor.get_current_image_data()
        resp.setHeader('Content-Type', 'image/jpeg')
        resp.setHeader('Content-Length', len(imagedata))
        resp.setHeader('Last-Modified',
                       strftime('%a, %d %b %Y %H:%M:%S +0000', gmtime()))
        resp.write(imagedata)
        return ''
Пример #3
0
def handle_image_edit(object, event):
    for field in object.Schema().fields():
        if field.getType() != \
                'plone.app.blob.subtypes.image.ExtensionBlobField':
            continue
        imageeditor = IImageEditorAdapter(object)
        imageeditor.set_field(field.__name__)
        # XXX Check if base image is different
        if str(field.get(object)) != imageeditor.stack[0]:
            imageeditor.clear_edits()
 def __init__(self, context, request):
     super(BrowserView, self).__init__(context, request)
     self.imageeditor = IImageEditorAdapter(context)
     self.imageeditor.set_field(request.get('field', ''))
 def __init__(self, context, request):
     super(BrowserView, self).__init__(context, request)
     self.imageeditor = IImageEditorAdapter(context)
     self.imageeditor.set_field(request.get('field', ''))