From cd906f78d663d47f97ad8b53cdf6f5f048975202 Mon Sep 17 00:00:00 2001
From: richard
Date: Wed, 20 Feb 2002 05:52:10 +0000
Subject: [PATCH] better error handling
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@642 57a73879-2fb5-44c3-a270-3262357dd7e2
---
roundup/cgi_client.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py
index 4ef96e7..164a252 100644
--- a/roundup/cgi_client.py
+++ b/roundup/cgi_client.py
@@ -15,7 +15,7 @@
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: cgi_client.py,v 1.104 2002-02-20 05:45:17 richard Exp $
+# $Id: cgi_client.py,v 1.105 2002-02-20 05:52:10 richard Exp $
__doc__ = """
WWW request handler (also used in the stand-alone server).
@@ -314,7 +314,9 @@ function submit_once() {
w = self.write
cn = self.classname
cl = self.db.classes[cn]
- props = ['id'] + cl.getprops(protected=0).keys()
+ idlessprops = cl.getprops(protected=0).keys()
+ props = ['id'] + idlessprops
+
# get the CSV module
try:
@@ -328,9 +330,10 @@ function submit_once() {
if self.form.has_key('rows'):
rows = self.form['rows'].value.splitlines()
p = csv.parser()
- idlessprops = props[1:]
found = {}
+ line = 0
for row in rows:
+ line += 1
values = p.parse(row)
# not a complete row, keep going
if not values: continue
@@ -339,6 +342,11 @@ function submit_once() {
nodeid, values = values[0], values[1:]
found[nodeid] = 1
+ # confirm correct weight
+ if len(idlessprops) != len(values):
+ w(_('Not enough values on line %(line)s'%{'line':line}))
+ return
+
# extract the new values
d = {}
for name, value in zip(idlessprops, values):
@@ -358,7 +366,10 @@ function submit_once() {
cl.retire(nodeid)
w(_('''You may edit the contents of the
- "%(classname)s" class using this form.
+ "%(classname)s" class using this form. The lines are full-featured
+ Comma-Separated-Value lines, so you may include commas and even
+ newlines by enclosing the values in double-quotes ("). Double
+ quotes themselves must be quoted by doubling ("").
Remove entries by deleting their line. Add
new entries by appending
them to the table - put an X in the id column.
''')%{'classname':cn})
@@ -1288,6 +1299,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
#
# $Log: not supported by cvs2svn $
+# Revision 1.104 2002/02/20 05:45:17 richard
+# Use the csv module for generating the form entry so it's correct.
+# [also noted the sf.net feature request id in the change log]
+#
# Revision 1.103 2002/02/20 05:05:28 richard
# . Added simple editing for classes that don't define a templated interface.
# - access using the admin "class list" interface
--
2.30.2