Commit 2b2d7822 authored by Andreas Jung's avatar Andreas Jung

- Collector #2261: Acquisition when creating objects via Webdav.

parent c6810f41
...@@ -10,6 +10,8 @@ Zope Changes ...@@ -10,6 +10,8 @@ Zope Changes
- Updated Zope 3 to bugfix release 3.3.1. - Updated Zope 3 to bugfix release 3.3.1.
- Collector #2261: Acquisition when creating objects via Webdav.
Zope 2.10.2 beta 1 (2007/01/14) Zope 2.10.2 beta 1 (2007/01/14)
Bugs fixed Bugs fixed
......
...@@ -427,6 +427,17 @@ class BaseRequest: ...@@ -427,6 +427,17 @@ class BaseRequest:
# BrowserDefault returns the object to be published # BrowserDefault returns the object to be published
# (usually self) and a sequence of names to traverse to # (usually self) and a sequence of names to traverse to
# find the method to be published. # find the method to be published.
# This is webdav support. The last object in the path
# should not be acquired. Instead, a NullResource should
# be given if it doesn't exist:
if (no_acquire_flag and
hasattr(object, 'aq_base') and
not hasattr(object,'__bobo_traverse__')):
if object.aq_parent is not object.aq_inner.aq_parent:
from webdav.NullResource import NullResource
object = NullResource(parents[-2], object.getId(), self).__of__(parents[-2])
if IBrowserPublisher.providedBy(object): if IBrowserPublisher.providedBy(object):
adapter = object adapter = object
else: else:
......
...@@ -27,6 +27,7 @@ class TestPUTFactory(unittest.TestCase): ...@@ -27,6 +27,7 @@ class TestPUTFactory(unittest.TestCase):
request['BODY'] = 'bar' request['BODY'] = 'bar'
request.environ['CONTENT_TYPE'] = 'text/plain' request.environ['CONTENT_TYPE'] = 'text/plain'
request.environ['REQUEST_METHOD'] = 'PUT' request.environ['REQUEST_METHOD'] = 'PUT'
request.environ['WEBDAV_SOURCE_PORT'] = 1
request._auth = auth_info request._auth = auth_info
except: except:
self.tearDown() self.tearDown()
...@@ -67,6 +68,23 @@ class TestPUTFactory(unittest.TestCase): ...@@ -67,6 +68,23 @@ class TestPUTFactory(unittest.TestCase):
put(request, request.RESPONSE) put(request, request.RESPONSE)
self.failUnless('doc' in self.folder.objectIds()) self.failUnless('doc' in self.folder.objectIds())
def testCollector2261(self):
from OFS.Folder import manage_addFolder
from OFS.DTMLMethod import addDTMLMethod
self.app.manage_addFolder('A', '')
addDTMLMethod(self.app, 'a', file='I am file a')
self.app.A.manage_addFolder('B', '')
request = self.app.REQUEST
# this should create 'a' within /A/B containing 'bar'
put = request.traverse('/A/B/a')
put(request, request.RESPONSE)
# PUT should no acquire A.a
self.assertEqual(str(self.app.A.a), 'I am file a', 'PUT factory not should acquire content')
# check for the newly created file
self.assertEqual(str(self.app.A.B.a), 'bar')
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
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