Skip to content

Commit 6d9aabc

Browse files
author
Ralf Schlatterbeck
committed
Fix linking of an existing item to a newly created item...
...e.g. edit action in web template is name="issue-1@link@msg" value="msg1" would trigger a traceback about an unbound variable. Add new regression test for this case.
1 parent 2d7f93f commit 6d9aabc

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ Fixes:
3636
- Fix styling of calendar to make it more usable, fixes issue2550608
3737
- Fix typo in email section of user guide, fixes issue2550607
3838
- Fix WSGI response code (thanks Peter P�ml)
39-
39+
- Fix linking of an existing item to a newly created item, e.g.
40+
edit action in web template is name="issue-1@link@msg" value="msg1"
41+
would trigger a traceback about an unbound variable.
42+
Add new regression test for this case.
4043

4144
2009-10-09 1.4.10 (r4374)
4245

roundup/cgi/actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,17 @@ def _editnodes(self, all_props, all_links):
478478
if linkid is None or linkid.startswith('-'):
479479
# linking to a new item
480480
if isinstance(propdef, hyperdb.Multilink):
481-
props[linkprop] = [newid]
481+
props[linkprop] = [nodeid]
482482
else:
483-
props[linkprop] = newid
483+
props[linkprop] = nodeid
484484
else:
485485
# linking to an existing item
486486
if isinstance(propdef, hyperdb.Multilink):
487487
existing = cl.get(linkid, linkprop)[:]
488488
existing.append(nodeid)
489489
props[linkprop] = existing
490490
else:
491-
props[linkprop] = newid
491+
props[linkprop] = nodeid
492492

493493
return '<br>'.join(m)
494494

test/test_actions.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def __call__(inner_self, *args, **kw):
249249
({'messages':hyperdb.Multilink('msg')
250250
,'content':hyperdb.String()
251251
,'files':hyperdb.Multilink('file')
252+
,'msg':hyperdb.Link('msg')
252253
})
253254
self.action = EditItemAction(self.client)
254255

@@ -302,6 +303,19 @@ def testLinkExisting(self):
302303
pass
303304
self.assertEqual(expect, self.result)
304305

306+
def testLinkNewToExisting(self):
307+
expect = [('create',(),{'msg':'1','title':'TEST'})]
308+
self.client.db.classes.get = lambda a, b:['23','42']
309+
self.client.parsePropsFromForm = lambda: \
310+
( {('issue','-1'):{'title':'TEST'},('msg','1'):{}}
311+
, [('issue','-1','msg',[('msg','1')])]
312+
)
313+
try :
314+
self.action.handle()
315+
except Redirect, msg:
316+
pass
317+
self.assertEqual(expect, self.result)
318+
305319
def test_suite():
306320
suite = unittest.TestSuite()
307321
suite.addTest(unittest.makeSuite(RetireActionTestCase))

0 commit comments

Comments
 (0)