Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #149 #153

Merged
merged 2 commits into from Mar 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,10 @@
Next Release
------------

- Raise a ValueError exception when the prototype
for a field in a sequence has no name. See
https://github.com/Pylons/deform/issues/149

0.9.7 (2013-03-06)
------------------

Expand Down
11 changes: 11 additions & 0 deletions deform/tests/test_widget.py
Expand Up @@ -1206,6 +1206,17 @@ def test_prototype_unicode(self):
self.assertEqual(url_unquote(result), 'abc')
self.assertEqual(protofield.cloned, True)

def test_prototype_field_has_no_name(self):
from deform.compat import url_unquote
renderer = DummyRenderer(text_type('abc'))
schema = DummySchema()
field = DummyField(schema, renderer)
widget = self._makeOne()
protofield = DummyField(None, renderer)
protofield.name = ''
field.children=[protofield]
self.assertRaises(ValueError, widget.prototype, field)

def test_prototype_str(self):
from deform.compat import url_unquote
renderer = DummyRenderer('abc')
Expand Down
3 changes: 3 additions & 0 deletions deform/widget.py
Expand Up @@ -1271,6 +1271,9 @@ def prototype(self, field):
# we clone the item field to bump the oid (for easier
# automated testing; finding last node)
item_field = field.children[0].clone()
if not item_field.name:
info = 'Prototype for %r has no name' % field
raise ValueError(info)
# NB: item_field default should already be set up
proto = item_field.render_template(self.item_template, parent=field)
if isinstance(proto, string_types):
Expand Down