Code

Features:
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 30 Jul 2001 06:17:45 +0000 (06:17 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 30 Jul 2001 06:17:45 +0000 (06:17 +0000)
 . Added ability for cgi newblah forms to indicate that the new node
   should be linked somewhere.
Fixed:
 . Fixed the agument handling for the roundup-admin find command.
 . Fixed handling of summary when no note supplied for newblah. Again.
 . Fixed detection of no form in htmltemplate Field display.

git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@168 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi_client.py
roundup/htmltemplate.py

index f6178d419cae085d08e79b5aae7cb6aa7c4b73b7..90f3760a645775bf72efc9900c4b2e21734413ec 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: cgi_client.py,v 1.10 2001-07-30 02:37:34 richard Exp $
+# $Id: cgi_client.py,v 1.11 2001-07-30 06:17:45 richard Exp $
 
 import os, cgi, pprint, StringIO, urlparse, re, traceback
 
@@ -321,7 +321,7 @@ class Client:
         # possibly perform a create
         keys = self.form.keys()
         num_re = re.compile('^\d+$')
-        if keys:
+        if [i for i in keys if i[0] != ':']:
             props = {}
             try:
                 keys = self.form.keys()
@@ -367,6 +367,32 @@ class Client:
                     props[key] = value
                 nid = cl.create(**props)
 
+                # link if necessary
+                for key in keys:
+                    print key,
+                    if key == ':multilink':
+                        value = self.form[key].value
+                        if type(value) != type([]): value = [value]
+                        for value in value:
+                            designator, property = value.split(':')
+                            print 'miltilinking to ', designator, property
+                            link, nodeid = roundupdb.splitDesignator(designator)
+                            link = self.db.classes[link]
+                            value = link.get(nodeid, property)
+                            value.append(nid)
+                            link.set(nodeid, **{property: value})
+                    elif key == ':link':
+                        value = self.form[key].value
+                        if type(value) != type([]): value = [value]
+                        for value in value:
+                            designator, property = value.split(':')
+                            print 'linking to ', designator, property
+                            link, nodeid = roundupdb.splitDesignator(designator)
+                            link = self.db.classes[link]
+                            link.set(nodeid, **{property: nid})
+                    else:
+                        print 'ignoring'
+
                 # if this item has messages, 
                 if (cl.getprops().has_key('messages') and
                         cl.getprops()['messages'].isMultilinkType and
@@ -406,8 +432,8 @@ class Client:
                             summary = note
                         m.append('\n%s\n'%note)
                     else:
-                        m.append('\nThis %s has been created through '
-                            'the web.\n'%cn)
+                        summary = 'This %s has been created through the web.'%cn
+                        m.append('\n%s\s'%summary)
 
                     # now create the message
                     content = '\n'.join(m)
@@ -499,6 +525,9 @@ class Client:
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.10  2001/07/30 02:37:34  richard
+# Temporary measure until we have decent schema migration...
+#
 # Revision 1.9  2001/07/30 01:25:07  richard
 # Default implementation is now "classic" rather than "extended" as one would
 # expect.
index 1356ed0692dae97f971b279f6a1c62c1218cb065..18204319d9d131c8ecd3235963f96b5bc50561b9 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: htmltemplate.py,v 1.13 2001-07-30 02:37:53 richard Exp $
+# $Id: htmltemplate.py,v 1.14 2001-07-30 06:17:45 richard Exp $
 
 import os, re, StringIO, urllib, cgi, errno
 
@@ -58,7 +58,7 @@ class Field(Base):
         to be edited
     '''
     def __call__(self, property, size=None, height=None, showid=0):
-        if not self.nodeid and self.form and self.filterspec is None:
+        if not self.nodeid and self.form is None and self.filterspec is None:
             return '[Field: not called from item]'
         propclass = self.properties[property]
         if self.nodeid:
@@ -711,12 +711,21 @@ def newitem(client, templates, db, classname, form, replace=re.compile(
     except:
         s = open(os.path.join(templates, classname+'.item')).read()
     w('<form action="new%s">'%classname)
+    for key in form.keys():
+        if key[0] == ':':
+            value = form[key].value
+            if type(value) != type([]): value = [value]
+            for value in value:
+                w('<input type="hidden" name="%s" value="%s">'%(key, value))
     replace = ItemTemplateReplace(globals, locals(), None, None)
     w(replace.go(s))
     w('</form>')
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.13  2001/07/30 02:37:53  richard
+# Temporary measure until we have decent schema migration.
+#
 # Revision 1.12  2001/07/30 01:24:33  richard
 # Handles new node display now.
 #