Skip to content

Commit 401f8e3

Browse files
author
Roche Compaan
committed
Two bug fixes and a feature.
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
1 parent 8e8f292 commit 401f8e3

File tree

3 files changed

+60
-20
lines changed

3 files changed

+60
-20
lines changed

roundup/cgi_client.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.84 2001-12-18 15:30:30 rochecompaan Exp $
18+
# $Id: cgi_client.py,v 1.85 2001-12-20 06:13:24 rochecompaan Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -419,12 +419,13 @@ def _handle_message(self):
419419
if self.form.has_key('__file'):
420420
file = self.form['__file']
421421
if file.filename:
422-
mime_type = mimetypes.guess_type(file.filename)[0]
422+
filename = file.filename.split('\\')[-1]
423+
mime_type = mimetypes.guess_type(filename)[0]
423424
if not mime_type:
424425
mime_type = "application/octet-stream"
425426
# create the new file entry
426427
files.append(self.db.file.create(type=mime_type,
427-
name=file.filename, content=file.file.read()))
428+
name=filename, content=file.file.read()))
428429

429430
# we don't want to do a message if none of the following is true...
430431
cn = self.classname
@@ -538,30 +539,30 @@ def newnode(self, message=None):
538539
# and some nice feedback for the user
539540
message = _('%(classname)s created ok')%{'classname': cn}
540541

541-
self.db.commit()
542542
# render the newly created issue
543+
self.db.commit()
543544
self.nodeid = nid
544545
self.pagehead('%s: %s'%(self.classname.capitalize(), nid),
545546
message)
546547
item = htmltemplate.ItemTemplate(self, self.TEMPLATES,
547548
self.classname)
548549
item.render(nid)
549550
self.pagefoot()
551+
return
550552
except:
551553
self.db.rollback()
552554
s = StringIO.StringIO()
553555
traceback.print_exc(None, s)
554556
message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
555-
else:
556-
self.pagehead(_('New %(classname)s')%{'classname':
557-
self.classname.capitalize()}, message)
557+
self.pagehead(_('New %(classname)s')%{'classname':
558+
self.classname.capitalize()}, message)
558559

559-
# call the template
560-
newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES,
561-
self.classname)
562-
newitem.render(self.form)
560+
# call the template
561+
newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES,
562+
self.classname)
563+
newitem.render(self.form)
563564

564-
self.pagefoot()
565+
self.pagefoot()
565566
newissue = newnode
566567

567568
def newuser(self, message=None):
@@ -1162,6 +1163,15 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
11621163

11631164
#
11641165
# $Log: not supported by cvs2svn $
1166+
# Revision 1.84 2001/12/18 15:30:30 rochecompaan
1167+
# Fixed bugs:
1168+
# . Fixed file creation and retrieval in same transaction in anydbm
1169+
# backend
1170+
# . Cgi interface now renders new issue after issue creation
1171+
# . Could not set issue status to resolved through cgi interface
1172+
# . Mail gateway was changing status back to 'chatting' if status was
1173+
# omitted as an argument
1174+
#
11651175
# Revision 1.83 2001/12/15 23:51:01 richard
11661176
# Tested the changes and fixed a few problems:
11671177
# . files are now attached to the issue as well as the message

roundup/htmltemplate.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: htmltemplate.py,v 1.47 2001-11-26 22:55:56 richard Exp $
18+
# $Id: htmltemplate.py,v 1.48 2001-12-20 06:13:24 rochecompaan Exp $
1919

2020
__doc__ = """
2121
Template engine.
@@ -112,6 +112,16 @@ def do_field(self, property, size=None, height=None, showid=0):
112112
if not self.nodeid and self.form is None and self.filterspec is None:
113113
return _('[Field: not called from item]')
114114
propclass = self.properties[property]
115+
if (isinstance(propclass, hyperdb.Link) or
116+
isinstance(propclass, hyperdb.Multilink)):
117+
linkcl = self.db.classes[propclass.classname]
118+
def sortfunc(a, b, cl=linkcl):
119+
if cl.getprops().has_key('order'):
120+
sort_on = 'order'
121+
else:
122+
sort_on = cl.labelprop()
123+
r = cmp(cl.get(a, sort_on), cl.get(b, sort_on))
124+
return r
115125
if self.nodeid:
116126
value = self.cl.get(self.nodeid, property, None)
117127
# TODO: remove this from the code ... it's only here for
@@ -142,15 +152,16 @@ def do_field(self, property, size=None, height=None, showid=0):
142152
size = size or 30
143153
s = '<input type="password" name="%s" size="%s">'%(property, size)
144154
elif isinstance(propclass, hyperdb.Link):
145-
linkcl = self.db.classes[propclass.classname]
146155
l = ['<select name="%s">'%property]
147156
k = linkcl.labelprop()
148157
if value is None:
149158
s = 'selected '
150159
else:
151160
s = ''
152161
l.append('<option %svalue="-1">- no selection -</option>'%s)
153-
for optionid in linkcl.list():
162+
options = linkcl.list()
163+
options.sort(sortfunc)
164+
for optionid in options:
154165
option = linkcl.get(optionid, k)
155166
s = ''
156167
if optionid == value:
@@ -165,8 +176,8 @@ def do_field(self, property, size=None, height=None, showid=0):
165176
l.append('</select>')
166177
s = '\n'.join(l)
167178
elif isinstance(propclass, hyperdb.Multilink):
168-
linkcl = self.db.classes[propclass.classname]
169179
list = linkcl.list()
180+
list.sort(sortfunc)
170181
height = height or min(len(list), 7)
171182
l = ['<select multiple name="%s" size="%s">'%(property, height)]
172183
k = linkcl.labelprop()
@@ -873,6 +884,18 @@ def render(self, form):
873884

874885
#
875886
# $Log: not supported by cvs2svn $
887+
# Revision 1.47 2001/11/26 22:55:56 richard
888+
# Feature:
889+
# . Added INSTANCE_NAME to configuration - used in web and email to identify
890+
# the instance.
891+
# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
892+
# signature info in e-mails.
893+
# . Some more flexibility in the mail gateway and more error handling.
894+
# . Login now takes you to the page you back to the were denied access to.
895+
#
896+
# Fixed:
897+
# . Lots of bugs, thanks Roché and others on the devel mailing list!
898+
#
876899
# Revision 1.46 2001/11/24 00:53:12 jhermann
877900
# "except:" is bad, bad , bad!
878901
#

roundup/hyperdb.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.42 2001-12-16 10:53:37 richard Exp $
18+
# $Id: hyperdb.py,v 1.43 2001-12-20 06:13:24 rochecompaan Exp $
1919

2020
__doc__ = """
2121
Hyperdatabase implementation, especially field types.
@@ -723,8 +723,11 @@ def sortfun(a, b, sort=sort, group=group, properties=self.getprops(),
723723
if (isinstance(propclass, String) or
724724
isinstance(propclass, Date)):
725725
# it might be a string that's really an integer
726-
av = int(av)
727-
bv = int(bv)
726+
try:
727+
av = int(av)
728+
bv = int(bv)
729+
except:
730+
pass
728731
if dir == '+':
729732
r = cmp(av, bv)
730733
if r != 0: return r
@@ -740,7 +743,7 @@ def sortfun(a, b, sort=sort, group=group, properties=self.getprops(),
740743
link = db.classes[propclass.classname]
741744
if av is None and bv is not None: return -1
742745
if av is not None and bv is None: return 1
743-
if av is None and bv is None: return 0
746+
if av is None and bv is None: continue
744747
if link.getprops().has_key('order'):
745748
if dir == '+':
746749
r = cmp(link.get(av, 'order'),
@@ -872,6 +875,10 @@ def Choice(name, *options):
872875

873876
#
874877
# $Log: not supported by cvs2svn $
878+
# Revision 1.42 2001/12/16 10:53:37 richard
879+
# take a copy of the node dict so that the subsequent set
880+
# operation doesn't modify the oldvalues structure
881+
#
875882
# Revision 1.41 2001/12/15 23:47:47 richard
876883
# Cleaned up some bare except statements
877884
#

0 commit comments

Comments
 (0)