From e57757118e00378dd1aa2508b1ee0fdf0e2f0eb4 Mon Sep 17 00:00:00 2001 From: rochecompaan Date: Thu, 20 Dec 2001 06:13:24 +0000 Subject: [PATCH] Bugs fixed: . Exception handling in hyperdb for strings-that-look-like numbers got lost somewhere . Internet Explorer submits full path for filename - we now strip away the path Features added: . Link and multilink properties are now displayed sorted in the cgi interface git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@478 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/cgi_client.py | 34 ++++++++++++++++++++++------------ roundup/htmltemplate.py | 31 +++++++++++++++++++++++++++---- roundup/hyperdb.py | 15 +++++++++++---- 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index e3dee1c..c8e1fef 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.84 2001-12-18 15:30:30 rochecompaan Exp $ +# $Id: cgi_client.py,v 1.85 2001-12-20 06:13:24 rochecompaan Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -419,12 +419,13 @@ class Client: if self.form.has_key('__file'): file = self.form['__file'] if file.filename: - mime_type = mimetypes.guess_type(file.filename)[0] + filename = file.filename.split('\\')[-1] + mime_type = mimetypes.guess_type(filename)[0] if not mime_type: mime_type = "application/octet-stream" # create the new file entry files.append(self.db.file.create(type=mime_type, - name=file.filename, content=file.file.read())) + name=filename, content=file.file.read())) # we don't want to do a message if none of the following is true... cn = self.classname @@ -538,8 +539,8 @@ class Client: # and some nice feedback for the user message = _('%(classname)s created ok')%{'classname': cn} - self.db.commit() # render the newly created issue + self.db.commit() self.nodeid = nid self.pagehead('%s: %s'%(self.classname.capitalize(), nid), message) @@ -547,21 +548,21 @@ class Client: self.classname) item.render(nid) self.pagefoot() + return except: self.db.rollback() s = StringIO.StringIO() traceback.print_exc(None, s) message = '
%s
'%cgi.escape(s.getvalue()) - else: - self.pagehead(_('New %(classname)s')%{'classname': - self.classname.capitalize()}, message) + self.pagehead(_('New %(classname)s')%{'classname': + self.classname.capitalize()}, message) - # call the template - newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES, - self.classname) - newitem.render(self.form) + # call the template + newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES, + self.classname) + newitem.render(self.form) - self.pagefoot() + self.pagefoot() newissue = newnode def newuser(self, message=None): @@ -1162,6 +1163,15 @@ def parsePropsFromForm(db, cl, form, nodeid=0): # # $Log: not supported by cvs2svn $ +# Revision 1.84 2001/12/18 15:30:30 rochecompaan +# Fixed bugs: +# . Fixed file creation and retrieval in same transaction in anydbm +# backend +# . Cgi interface now renders new issue after issue creation +# . Could not set issue status to resolved through cgi interface +# . Mail gateway was changing status back to 'chatting' if status was +# omitted as an argument +# # Revision 1.83 2001/12/15 23:51:01 richard # Tested the changes and fixed a few problems: # . files are now attached to the issue as well as the message diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 042e7e5..ea2981f 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.47 2001-11-26 22:55:56 richard Exp $ +# $Id: htmltemplate.py,v 1.48 2001-12-20 06:13:24 rochecompaan Exp $ __doc__ = """ Template engine. @@ -112,6 +112,16 @@ class TemplateFunctions: 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 (isinstance(propclass, hyperdb.Link) or + isinstance(propclass, hyperdb.Multilink)): + linkcl = self.db.classes[propclass.classname] + def sortfunc(a, b, cl=linkcl): + if cl.getprops().has_key('order'): + sort_on = 'order' + else: + sort_on = cl.labelprop() + r = cmp(cl.get(a, sort_on), cl.get(b, sort_on)) + return r if self.nodeid: value = self.cl.get(self.nodeid, property, None) # TODO: remove this from the code ... it's only here for @@ -142,7 +152,6 @@ class TemplateFunctions: size = size or 30 s = ''%(property, size) elif isinstance(propclass, hyperdb.Link): - linkcl = self.db.classes[propclass.classname] l = ['') s = '\n'.join(l) elif isinstance(propclass, hyperdb.Multilink): - linkcl = self.db.classes[propclass.classname] list = linkcl.list() + list.sort(sortfunc) height = height or min(len(list), 7) l = ['