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 @@
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)
------------------
......
......@@ -19,6 +19,7 @@ __docformat__ = 'restructuredtext'
import urllib
from zope.event import notify
from zope.exceptions.interfaces import UserError
from zope.security.interfaces import Unauthorized
from zope.security import canWrite
......@@ -31,6 +32,7 @@ from zope.copypastemove.interfaces import IPrincipalClipboard
from zope.copypastemove.interfaces import IObjectCopier, IObjectMover
from zope.copypastemove.interfaces import IContainerItemRenamer
from zope.annotation.interfaces import IAnnotations
from zope.lifecycleevent import ObjectModifiedEvent, Attributes
from zope.app import zapi
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
......@@ -218,7 +220,8 @@ class Contents(BrowserView):
item = self.context[id]
dc = IDCDescriptiveProperties(item)
dc.title = new
notify(ObjectModifiedEvent(item, Attributes(IZopeDublinCore, 'title')))
def hasAdding(self):
"""Returns true if an adding view is available."""
adding = zapi.queryMultiAdapter((self.context, self.request), name="+")
......
......@@ -20,6 +20,9 @@ from unittest import TestCase, TestSuite, main, makeSuite
from zope.interface import Interface, implements
from zope.security import checker
from zope.traversing.api import traverse
from zope.component.eventtesting import getEvents
from zope.annotation.interfaces import IAnnotations
from zope.copypastemove import ContainerItemRenamer
from zope.copypastemove import ObjectMover, ObjectCopier
......@@ -158,6 +161,45 @@ class BaseTestContentsBrowserView(PlacefulSetup):
urls = map(lambda x: x['url'], info_list)
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):
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