Skip to content

Commit 01fea71

Browse files
author
Richard Jones
committed
can now unset values in CSV editing [SF#704788]
1 parent aa7fca4 commit 01fea71

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ are given with the most recent entry first.
77
- fixed rdbms table update detection logic (sf bug 703297)
88
- required String properties not being flagged (thanks Ajit George)
99
- only look for CSV files when importing (thanks Dan Grassi)
10+
- can now unset values in CSV editing (sf bug 704788)
1011

1112

1213
2003-02-27 0.5.6

roundup/cgi/client.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.65.2.5 2003-03-15 23:30:07 richard Exp $
1+
# $Id: client.py,v 1.65.2.6 2003-03-19 02:50:12 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -827,6 +827,9 @@ def newItemPermission(self, props):
827827
return 1
828828
return 0
829829

830+
#
831+
# More actions
832+
#
830833
def editCSVAction(self):
831834
''' Performs an edit of all of a class' items in one go.
832835
@@ -872,6 +875,12 @@ def editCSVAction(self):
872875
nodeid, values = values[0], values[1:]
873876
found[nodeid] = 1
874877

878+
# see if the node exists
879+
if cl.hasnode(nodeid):
880+
exists = 1
881+
else:
882+
exists = 0
883+
875884
# confirm correct weight
876885
if len(idlessprops) != len(values):
877886
self.error_message.append(
@@ -881,16 +890,23 @@ def editCSVAction(self):
881890
# extract the new values
882891
d = {}
883892
for name, value in zip(idlessprops, values):
893+
prop = cl.properties[name]
884894
value = value.strip()
885895
# only add the property if it has a value
886896
if value:
887897
# if it's a multilink, split it
888-
if isinstance(cl.properties[name], hyperdb.Multilink):
898+
if isinstance(prop, hyperdb.Multilink):
889899
value = value.split(':')
890900
d[name] = value
901+
elif exists:
902+
# nuke the existing value
903+
if isinstance(prop, hyperdb.Multilink):
904+
d[name] = []
905+
else:
906+
d[name] = None
891907

892908
# perform the edit
893-
if cl.hasnode(nodeid):
909+
if exists:
894910
# edit existing
895911
cl.set(nodeid, **d)
896912
else:

0 commit comments

Comments
 (0)