Code

Fix issue2550512
authorstefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 19 Feb 2009 23:32:23 +0000 (23:32 +0000)
committerstefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 19 Feb 2009 23:32:23 +0000 (23:32 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4148 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi/templating.py

index f32b1e0e2c6d43748c873d8c391533e1ee785a44..4fc6e5dd90dc7a4ea0694542acdc9c46e78324f0 100644 (file)
@@ -530,24 +530,10 @@ class HTMLClass(HTMLInputMixin, HTMLPermissions):
         for klass, htmlklass in propclasses:
             if not isinstance(prop, klass):
                 continue
-            if form.has_key(item):
-                if isinstance(prop, hyperdb.Multilink):
-                    value = lookupIds(self._db, prop,
-                        handleListCGIValue(form[item]), fail_ok=1)
-                elif isinstance(prop, hyperdb.Link):
-                    value = form.getfirst(item).strip()
-                    if value:
-                        value = lookupIds(self._db, prop, [value],
-                            fail_ok=1)[0]
-                    else:
-                        value = None
-                else:
-                    value = form.getfirst(item).strip() or None
+            if isinstance(prop, hyperdb.Multilink):
+                value = []
             else:
-                if isinstance(prop, hyperdb.Multilink):
-                    value = []
-                else:
-                    value = None
+                value = None
             return htmlklass(self._client, self._classname, None, prop, item,
                 value, self._anonymous)
 
@@ -1206,6 +1192,25 @@ class HTMLProperty(HTMLInputMixin, HTMLPermissions):
         else:
             self._formname = name
 
+        # If no value is already present for this property, see if one
+        # is specified in the current form.
+        form = self._client.form
+        if not self._value and form.has_key(self._formname):
+            if isinstance(prop, hyperdb.Multilink):
+                value = lookupIds(self._db, prop,
+                                  handleListCGIValue(form[self._formname]),
+                                  fail_ok=1)
+            elif isinstance(prop, hyperdb.Link):
+                value = form.getfirst(self._formname).strip()
+                if value:
+                    value = lookupIds(self._db, prop, [value],
+                                      fail_ok=1)[0]
+                else:
+                    value = None
+            else:
+                value = form.getfirst(self._formname).strip() or None
+            self._value = value
+
         HTMLInputMixin.__init__(self)
 
     def __repr__(self):