[Checkins] SVN: zope.app.file/trunk/ Merge from the 3.4 branch:
Philipp von Weitershausen
philikon at philikon.de
Fri Nov 9 14:49:19 EST 2007
Log message for revision 81668:
Merge from the 3.4 branch:
------------------------------------------------------------------------
r81664 | philikon | 2007-11-09 20:43:23 +0100 (Fri, 09 Nov 2007) | 7 lines
Include information about which attributes changed in the
``IObjectModifiedEvent`` after upload.
This fixes https://bugs.launchpad.net/zope3/+bug/98483.
Changed:
U zope.app.file/trunk/CHANGES.txt
U zope.app.file/trunk/src/zope/app/file/browser/file.py
-=-
Modified: zope.app.file/trunk/CHANGES.txt
===================================================================
--- zope.app.file/trunk/CHANGES.txt 2007-11-09 19:47:00 UTC (rev 81667)
+++ zope.app.file/trunk/CHANGES.txt 2007-11-09 19:49:18 UTC (rev 81668)
@@ -2,6 +2,14 @@
CHANGES
=======
+3.4.2 (2007-11-09)
+------------------
+
+- Include information about which attributes changed in the
+ ``IObjectModifiedEvent`` after upload.
+
+ This fixes https://bugs.launchpad.net/zope3/+bug/98483.
+
3.4.1 (2007-10-31)
------------------
Modified: zope.app.file/trunk/src/zope/app/file/browser/file.py
===================================================================
--- zope.app.file/trunk/src/zope/app/file/browser/file.py 2007-11-09 19:47:00 UTC (rev 81667)
+++ zope.app.file/trunk/src/zope/app/file/browser/file.py 2007-11-09 19:49:18 UTC (rev 81668)
@@ -339,12 +339,12 @@
We install an event logger so we can see the events generated.
>>> def eventLog(event):
- ... print event
+ ... print event.__class__.__name__, event.descriptions[0].attributes
>>> zope.event.subscribers.append(eventLog)
>>> view.setData({'contentType': 'text/plain; charset=ISO-8859-13',
... 'data': u'text \u0105'}) # doctest:+ELLIPSIS
- <zope.app.event.objectevent.ObjectModifiedEvent object at ...>
+ ObjectModifiedEvent ('data', 'contentType')
u'Updated on ${date_time}'
>>> view.context.contentType
@@ -441,18 +441,28 @@
def setData(self, data):
charset = extractCharset(data['contentType'])
try:
- self.context.data = data['data'].encode(charset)
+ encodeddata = data['data'].encode(charset)
except LookupError:
raise UnknownCharset(charset)
except UnicodeEncodeError:
raise CharsetTooWeak(charset)
- self.context.contentType = data['contentType']
+
+ 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)
- event = lifecycleevent.ObjectModifiedEvent(self.context)
- zope.event.notify(event)
-
return _("Updated on ${date_time}",
mapping={'date_time': formatter.format(datetime.utcnow())})
More information about the Checkins
mailing list