Skip to content

Commit

Permalink
Fix to pass resource name from webdav PUT to createObject
Browse files Browse the repository at this point in the history
  • Loading branch information
datakurre committed May 18, 2015
1 parent b3d554e commit 9a16c50
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
2.3.1 (unreleased)
------------------

- Fix issue where webdav PUT created items with empty id
[datakurre]
- fix #27: createContent ignores empty fields
[jensens]

Expand Down
2 changes: 1 addition & 1 deletion plone/dexterity/filerepresentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def __call__(self, name, contentType, data):
typeObjectName
)

obj = createObject(targetType.factory)
obj = createObject(targetType.factory, name)

if hasattr(obj, '_setPortalTypeName'):
obj._setPortalTypeName(targetType.getId())
Expand Down
60 changes: 60 additions & 0 deletions plone/dexterity/tests/test_webdav.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,66 @@ def factory(*args, **kwargs):
factory('test.html', 'text/html', '<html />')
)

def test_file_factory_content_type_factory_utility(self):
container_mock = self.mocker.mock()
child_fti_mock = self.mocker.mock()
container_fti_mock = self.mocker.mock()
ctr_mock = self.mocker.mock()
pt_mock = self.mocker.mock()

getToolByName_mock = self.mocker.replace(
'Products.CMFCore.utils.getToolByName'
)

self.expect(
getToolByName_mock(
container_mock, 'content_type_registry', None
)
).result(ctr_mock)

self.expect(
getToolByName_mock(
container_mock, 'portal_types')).result(pt_mock)

self.expect(
ctr_mock.findTypeName('test.html', 'text/html', '<html />')
).result('childtype')

self.expect(
pt_mock.getTypeInfo('childtype')
).result(child_fti_mock)

self.expect(
pt_mock.getTypeInfo(container_mock)
).result(container_fti_mock)

self.expect(
container_fti_mock.allowType('childtype')
).result(True)

self.expect(
child_fti_mock.isConstructionAllowed(container_mock)
).result(True)

self.expect(
child_fti_mock.getId()
).result('childtype')

self.expect(child_fti_mock.product).result(None)
self.expect(child_fti_mock.factory).result('childtype-factory')

def factory(*args, **kwargs):
return Item(*args, **kwargs)
self.mock_utility(factory, IFactory, name=u'childtype-factory')

factory = DefaultFileFactory(container_mock)

self.replay()

item = factory('test.html', 'text/html', '<html />')

self.assertEqual('test.html', item.id)

def test_readfile_mimetype_no_message_no_fields(self):

class ITest(Interface):
Expand Down

0 comments on commit 9a16c50

Please sign in to comment.