class ImageWatchDogEditForm(controlpanel.RegistryEditForm):
    schema = IImageWatchDogSettings
    label = _('Image WatchDog settings')
    description = _('Settings to configure Image WatchDog in Plone.')

    @button.buttonAndHandler(__(u"Save"), name='save')
    def handleSave(self, action):
        data, errors = self.extractData()
        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved."),
                                                      "info")
        self.request.response.redirect(self.request.getURL())

    @button.buttonAndHandler(__(u"Cancel"), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u"Changes canceled."),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))

    @button.buttonAndHandler(
        _(u"Save and Migrate"),
        name='migrate',
        condition=lambda enabled: bool(
            getUtility(IRegistry).forInterface(IImageWatchDogSettings).enabled)
    )
    def handleMigrate(self, action):
        data, errors = self.extractData()
        self.applyChanges(data)
        migrate_images(self.context)
        IStatusMessage(self.request).addStatusMessage(_(u"Migration done."),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
예제 #2
0
class IImageWatchDogSettings(Interface):
    """ Interface for the control panel form.
    """

    enabled = schema.Bool(
        title=_(u"Enabled"),
        description=_(u"Activate the convertion to PNG."),
        required=False,
    )

    source_formats = schema.List(
        title=_(u"Source formats"),
        description=_(u"Only image in these format will be converted to PNG."),
        required=False,
        default=['JPEG', 'GIF'],
        # we are going to list only the main content types in the widget
        value_type=schema.Choice(vocabulary=image_formats),
    )

    optimize = schema.Bool(
        title=_(u"Optimize PNG"),
        description=_(
            u"Instructs the PNG writer to make the output file as small as "
            u"possible. This includes extra processing in order to find "
            u"optimal encoder settings."),
        required=False,
    )

    sleep = schema.Int(
        title=_(u"Migration delay (milliseconds)"),
        description=_(
            u"Migrating images to PNG is an expensive process, this "
            u"parameter indicates a delay between every processed image. 0 "
            u"means no delay, more fast, but CPU intensive, bigger values "
            u"are nicer with the CPU but will slow down the process."),
        required=False,
        default=0,
    )

    threshold = schema.Int(
        title=_(u"Transaction threshold"),
        description=_(
            u"Migrating images in one single transaction could be a RAM "
            u"intensive process. This parameter is the number of images "
            u"processed in a single transaction. 0 means one single "
            u"transaction, more fast, but RAM intensive, small values are "
            u"nicer with the RAM but will slow down the process."),
        required=False,
        default=0,
    )
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(
         _(u"Changes canceled."),
         "info")
     self.request.response.redirect("%s/%s" % (
         self.context.absolute_url(),
         self.control_panel_view))
 def handleSave(self, action):
     data, errors = self.extractData()
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(
         _(u"Changes saved."),
         "info")
     self.request.response.redirect(self.request.getURL())
 def handleMigrate(self, action):
     data, errors = self.extractData()
     self.applyChanges(data)
     migrate_images(self.context)
     IStatusMessage(self.request).addStatusMessage(_(u"Migration done."),
                                                   "info")
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
 def handleMigrate(self, action):
     data, errors = self.extractData()
     self.applyChanges(data)
     migrate_images(self.context)
     IStatusMessage(self.request).addStatusMessage(
         _(u"Migration done."),
         "info")
     self.request.response.redirect("%s/%s" % (
         self.context.absolute_url(),
         self.control_panel_view))
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Changes canceled."),
                                                   "info")
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
 def handleSave(self, action):
     data, errors = self.extractData()
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved."),
                                                   "info")
     self.request.response.redirect(self.request.getURL())
from zope import schema
from zope.interface import Interface
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from openmultimedia.imagewatchdog import _

image_formats = SimpleVocabulary(
    [SimpleTerm(value=u'JPEG', title=_(u'.jpg images')),
     SimpleTerm(value=u'GIF', title=_(u'.gif images'))]
)


class IImageWatchDogSettings(Interface):
    """ Interface for the control panel form.
    """

    enabled = schema.Bool(
        title=_(u"Enabled"),
        description=_(u"Activate the convertion to PNG."),
        required=False,
    )

    source_formats = schema.List(
        title=_(u"Source formats"),
        description=_(u"Only image in these format will be converted to PNG."),
        required=False,
        default=['JPEG', 'GIF'],
        # we are going to list only the main content types in the widget
        value_type=schema.Choice(
            vocabulary=image_formats),
    )
예제 #10
0
from zope import schema
from zope.interface import Interface
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from openmultimedia.imagewatchdog import _

image_formats = SimpleVocabulary([
    SimpleTerm(value=u'JPEG', title=_(u'.jpg images')),
    SimpleTerm(value=u'GIF', title=_(u'.gif images'))
])


class IImageWatchDogSettings(Interface):
    """ Interface for the control panel form.
    """

    enabled = schema.Bool(
        title=_(u"Enabled"),
        description=_(u"Activate the convertion to PNG."),
        required=False,
    )

    source_formats = schema.List(
        title=_(u"Source formats"),
        description=_(u"Only image in these format will be converted to PNG."),
        required=False,
        default=['JPEG', 'GIF'],
        # we are going to list only the main content types in the widget
        value_type=schema.Choice(vocabulary=image_formats),
    )