Merge from the trunk:

------------------------------------------------------------------------
r81655 | philikon | 2007-11-09 20:18:03 +0100 (Fri, 09 Nov 2007) | 6 lines

Send ``IObjectModifiedEvent`` when changing the title through the
``@@contents.html`` view.

This fixes https://bugs.edge.launchpad.net/zope3/+bug/98483.
parent fc72d746
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
CHANGES CHANGES
======= =======
3.5.3 (2007-11-09)
------------------
- Send ``IObjectModifiedEvent`` when changing the title through the
``@@contents.html`` view.
This fixes https://bugs.edge.launchpad.net/zope3/+bug/98483.
3.5.2 (2007-11-01) 3.5.2 (2007-11-01)
------------------ ------------------
......
...@@ -19,6 +19,7 @@ __docformat__ = 'restructuredtext' ...@@ -19,6 +19,7 @@ __docformat__ = 'restructuredtext'
import urllib import urllib
from zope.event import notify
from zope.exceptions.interfaces import UserError from zope.exceptions.interfaces import UserError
from zope.security.interfaces import Unauthorized from zope.security.interfaces import Unauthorized
from zope.security import canWrite from zope.security import canWrite
...@@ -31,6 +32,7 @@ from zope.copypastemove.interfaces import IPrincipalClipboard ...@@ -31,6 +32,7 @@ from zope.copypastemove.interfaces import IPrincipalClipboard
from zope.copypastemove.interfaces import IObjectCopier, IObjectMover from zope.copypastemove.interfaces import IObjectCopier, IObjectMover
from zope.copypastemove.interfaces import IContainerItemRenamer from zope.copypastemove.interfaces import IContainerItemRenamer
from zope.annotation.interfaces import IAnnotations from zope.annotation.interfaces import IAnnotations
from zope.lifecycleevent import ObjectModifiedEvent, Attributes
from zope.app import zapi from zope.app import zapi
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
...@@ -218,6 +220,7 @@ class Contents(BrowserView): ...@@ -218,6 +220,7 @@ class Contents(BrowserView):
item = self.context[id] item = self.context[id]
dc = IDCDescriptiveProperties(item) dc = IDCDescriptiveProperties(item)
dc.title = new dc.title = new
notify(ObjectModifiedEvent(item, Attributes(IZopeDublinCore, 'title')))
def hasAdding(self): def hasAdding(self):
"""Returns true if an adding view is available.""" """Returns true if an adding view is available."""
......
...@@ -20,6 +20,9 @@ from unittest import TestCase, TestSuite, main, makeSuite ...@@ -20,6 +20,9 @@ from unittest import TestCase, TestSuite, main, makeSuite
from zope.interface import Interface, implements from zope.interface import Interface, implements
from zope.security import checker from zope.security import checker
from zope.traversing.api import traverse from zope.traversing.api import traverse
from zope.component.eventtesting import getEvents
from zope.annotation.interfaces import IAnnotations from zope.annotation.interfaces import IAnnotations
from zope.copypastemove import ContainerItemRenamer from zope.copypastemove import ContainerItemRenamer
from zope.copypastemove import ObjectMover, ObjectCopier from zope.copypastemove import ObjectMover, ObjectCopier
...@@ -158,6 +161,45 @@ class BaseTestContentsBrowserView(PlacefulSetup): ...@@ -158,6 +161,45 @@ class BaseTestContentsBrowserView(PlacefulSetup):
urls = map(lambda x: x['url'], info_list) urls = map(lambda x: x['url'], info_list)
self.assert_('subcontainer' in urls) self.assert_('subcontainer' in urls)
def testChangeTitle(self):
container = self._TestView__newContext()
document = Document()
container['document'] = document
from zope.dublincore.interfaces import IDCDescriptiveProperties
class FauxDCDescriptiveProperties(object):
implements(IDCDescriptiveProperties)
__Security_checker__ = checker.Checker(
{"title": "zope.Public",
},
{"title": "zope.app.dublincore.change"})
def __init__(self, context):
self.context = context
def setTitle(self, title):
self.context.title = title
def getTitle(self):
return self.context.title
title = property(getTitle, setTitle)
ztapi.provideAdapter(IDocument, IDCDescriptiveProperties, FauxDCDescriptiveProperties)
fc = self._TestView__newView(container)
dc = IDCDescriptiveProperties(document)
fc.request.form.update({'retitle_id': 'document', 'new_value': 'new'})
fc.changeTitle()
events = getEvents()
self.assertEquals(dc.title, 'new')
self.failIf('title' not in events[-1].descriptions[0].attributes)
class IDocument(Interface): class IDocument(Interface):
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment