예제 #1
0
    def setData(self, data):
        charset = extractCharset(data['contentType'])
        try:
            encodeddata = data['data'].encode(charset)
        except LookupError:
            raise UnknownCharset(charset)
        except UnicodeEncodeError:
            raise CharsetTooWeak(charset)

        modified = []
        if encodeddata != self.context.data:
            self.context.data = encodeddata
            modified.append('data')

        if self.context.contentType != data['contentType']:
            self.context.contentType = data['contentType']
            modified.append('contentType')
        formatter = self.request.locale.dates.getFormatter(
            'dateTime', 'medium')
        if modified:
            event = lifecycleevent.ObjectModifiedEvent(
                self.context, lifecycleevent.Attributes(IFile, *modified))
            zope.event.notify(event)

        return _("Updated on ${date_time}",
                 mapping={'date_time': formatter.format(datetime.utcnow())})
예제 #2
0
파일: file.py 프로젝트: CGTIC/Plone_SP
    def setData(self, data):
        charset = extractCharset(data['contentType'])
        try:
            encodeddata = data['data'].encode(charset)
        except LookupError:
            raise UnknownCharset(charset)
        except UnicodeEncodeError:
            raise CharsetTooWeak(charset)
        
        modified = []
        if encodeddata != self.context.data:
            self.context.data = encodeddata
            modified.append('data')
        
        if self.context.contentType != data['contentType']:
            self.context.contentType = data['contentType']
            modified.append('contentType')
        formatter = self.request.locale.dates.getFormatter('dateTime',
                                                           'medium')
        if modified:
            event = lifecycleevent.ObjectModifiedEvent(
                self.context,
                lifecycleevent.Attributes(IFile, *modified))
            zope.event.notify(event)

        return _("Updated on ${date_time}",
                 mapping={'date_time': formatter.format(datetime.utcnow())})
예제 #3
0
    def update_object(self, data, contenttype):
        self.context.contentType = contenttype

        descriptor = lifecycleevent.Attributes(IFile, "contentType")

        # Update *only* if a new value is specified
        if data:
            self.context.data = data
            descriptor.attributes += ("data", )

        event = lifecycleevent.ObjectModifiedEvent(self.context, descriptor)
        zope.event.notify(event)

        formatter = self.request.locale.dates.getFormatter(
            'dateTime', 'medium')
        return _("Updated on ${date_time}",
                 mapping={'date_time': formatter.format(datetime.utcnow())})
예제 #4
0
파일: file.py 프로젝트: CGTIC/Plone_SP
    def update_object(self, data, contenttype):
        self.context.contentType = contenttype

        descriptor = lifecycleevent.Attributes(IFile, "contentType")

        # Update *only* if a new value is specified
        if data:
            self.context.data = data
            descriptor.attributes += "data",

        event = lifecycleevent.ObjectModifiedEvent(self.context, descriptor)
        zope.event.notify(event)

        formatter = self.request.locale.dates.getFormatter(
            'dateTime', 'medium')
        return _("Updated on ${date_time}",
                 mapping={'date_time': formatter.format(datetime.utcnow())})