|
1 | | -#$Id: actions.py,v 1.65 2007-04-19 12:18:50 stefan Exp $ |
| 1 | +#$Id: actions.py,v 1.66 2007-04-27 00:17:11 richard Exp $ |
2 | 2 |
|
3 | 3 | import re, cgi, StringIO, urllib, Cookie, time, random, csv, codecs |
4 | 4 |
|
@@ -367,13 +367,16 @@ def _editnodes(self, all_props, all_links): |
367 | 367 | deps = {} |
368 | 368 | links = {} |
369 | 369 | for cn, nodeid, propname, vlist in all_links: |
370 | | - if not all_props.has_key((cn, nodeid)): |
| 370 | + if not (nodeid or all_props.has_key((cn, nodeid))): |
371 | 371 | # link item to link to doesn't (and won't) exist |
372 | 372 | continue |
373 | | - for value in vlist: |
374 | | - if not all_props.has_key(value): |
| 373 | + |
| 374 | + for vcn, vid in vlist: |
| 375 | + if vid == '-1': vid = None |
| 376 | + if not (vid or all_props.has_key((vcn, vid))): |
375 | 377 | # link item to link to doesn't (and won't) exist |
376 | 378 | continue |
| 379 | + value = (vcn, vid) |
377 | 380 | deps.setdefault((cn, nodeid), []).append(value) |
378 | 381 | links.setdefault(value, []).append((cn, nodeid, propname)) |
379 | 382 |
|
@@ -401,36 +404,34 @@ def _editnodes(self, all_props, all_links): |
401 | 404 | m = [] |
402 | 405 | for needed in order: |
403 | 406 | props = all_props[needed] |
404 | | - if not props: |
405 | | - # nothing to do |
406 | | - continue |
407 | | - cn, nodeid = needed |
408 | | - |
409 | | - if nodeid is not None and int(nodeid) > 0: |
410 | | - # make changes to the node |
411 | | - props = self._changenode(cn, nodeid, props) |
412 | | - |
413 | | - # and some nice feedback for the user |
414 | | - if props: |
415 | | - info = ', '.join(map(self._, props.keys())) |
416 | | - m.append( |
417 | | - self._('%(class)s %(id)s %(properties)s edited ok') |
418 | | - % {'class':cn, 'id':nodeid, 'properties':info}) |
| 407 | + if props: |
| 408 | + cn, nodeid = needed |
| 409 | + |
| 410 | + if nodeid is not None and int(nodeid) > 0: |
| 411 | + # make changes to the node |
| 412 | + props = self._changenode(cn, nodeid, props) |
| 413 | + |
| 414 | + # and some nice feedback for the user |
| 415 | + if props: |
| 416 | + info = ', '.join(map(self._, props.keys())) |
| 417 | + m.append( |
| 418 | + self._('%(class)s %(id)s %(properties)s edited ok') |
| 419 | + % {'class':cn, 'id':nodeid, 'properties':info}) |
| 420 | + else: |
| 421 | + m.append(self._('%(class)s %(id)s - nothing changed') |
| 422 | + % {'class':cn, 'id':nodeid}) |
419 | 423 | else: |
420 | | - m.append(self._('%(class)s %(id)s - nothing changed') |
421 | | - % {'class':cn, 'id':nodeid}) |
422 | | - else: |
423 | | - assert props |
| 424 | + assert props |
424 | 425 |
|
425 | | - # make a new node |
426 | | - newid = self._createnode(cn, props) |
427 | | - if nodeid is None: |
428 | | - self.nodeid = newid |
429 | | - nodeid = newid |
| 426 | + # make a new node |
| 427 | + newid = self._createnode(cn, props) |
| 428 | + if nodeid is None: |
| 429 | + self.nodeid = newid |
| 430 | + nodeid = newid |
430 | 431 |
|
431 | | - # and some nice feedback for the user |
432 | | - m.append(self._('%(class)s %(id)s created') |
433 | | - % {'class':cn, 'id':newid}) |
| 432 | + # and some nice feedback for the user |
| 433 | + m.append(self._('%(class)s %(id)s created') |
| 434 | + % {'class':cn, 'id':newid}) |
434 | 435 |
|
435 | 436 | # fill in new ids in links |
436 | 437 | if links.has_key(needed): |
|
0 commit comments