Skip to content

Commit 6f858f6

Browse files
author
Richard Jones
committed
feature [SF#473127]: Filenames.
I modified the file.index and htmltemplate source so that the filename is used in the link and the creation information is displayed.
1 parent 236f83b commit 6f858f6

File tree

4 files changed

+102
-61
lines changed

4 files changed

+102
-61
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ are given with the most recent entry first.
44
2001-10-?? - 0.3.0
55
Feature:
66
. MailGW now moves 'unread' to 'chatting' on receiving e-mail for an issue.
7+
. feature #473127: Filenames. I modified the file.index and htmltemplate
8+
source so that the filename is used in the link and the creation
9+
information is displayed.
710
Admin Tool (roundup-admin):
811
. Interactive mode for running multiple (independant at present) commands.
912
. Tabular display of nodes.

roundup/cgi_client.py

Lines changed: 61 additions & 49 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.36 2001-10-21 04:44:50 richard Exp $
18+
# $Id: cgi_client.py,v 1.37 2001-10-21 07:26:35 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
2121
import base64, Cookie, time
@@ -618,57 +618,64 @@ def main(self, dre=re.compile(r'([^\d]+)(\d+)'),
618618
path = self.split_path
619619
if not path or path[0] in ('', 'index'):
620620
self.index()
621-
elif len(path) == 1:
622-
if path[0] == 'list_classes':
623-
self.classes()
624-
return
625-
if path[0] == 'login':
626-
self.login()
627-
return
628-
if path[0] == 'login_action':
629-
self.login_action()
630-
return
631-
if path[0] == 'newuser_action':
632-
self.newuser_action()
633-
return
634-
if path[0] == 'logout':
635-
self.logout()
636-
return
637-
m = dre.match(path[0])
638-
if m:
639-
self.classname = m.group(1)
640-
self.nodeid = m.group(2)
641-
try:
642-
cl = self.db.classes[self.classname]
643-
except KeyError:
644-
raise NotFound
645-
try:
646-
cl.get(self.nodeid, 'id')
647-
except IndexError:
648-
raise NotFound
649-
try:
650-
func = getattr(self, 'show%s'%self.classname)
651-
except AttributeError:
652-
raise NotFound
653-
func()
654-
return
655-
m = nre.match(path[0])
656-
if m:
657-
self.classname = m.group(1)
658-
try:
659-
func = getattr(self, 'new%s'%self.classname)
660-
except AttributeError:
661-
raise NotFound
662-
func()
663-
return
664-
self.classname = path[0]
621+
elif not path:
622+
raise 'ValueError', 'Path not understood'
623+
624+
#
625+
# Everthing ignores path[1:]
626+
#
627+
# The file download link generator actually relies on this - it
628+
# appends the name of the file to the URL so the download file name
629+
# is correct, but doesn't actually use it.
630+
action = path[0]
631+
if action == 'list_classes':
632+
self.classes()
633+
return
634+
if action == 'login':
635+
self.login()
636+
return
637+
if action == 'login_action':
638+
self.login_action()
639+
return
640+
if action == 'newuser_action':
641+
self.newuser_action()
642+
return
643+
if action == 'logout':
644+
self.logout()
645+
return
646+
m = dre.match(action)
647+
if m:
648+
self.classname = m.group(1)
649+
self.nodeid = m.group(2)
665650
try:
666-
self.db.getclass(self.classname)
651+
cl = self.db.classes[self.classname]
667652
except KeyError:
668653
raise NotFound
669-
self.list()
670-
else:
671-
raise 'ValueError', 'Path not understood'
654+
try:
655+
cl.get(self.nodeid, 'id')
656+
except IndexError:
657+
raise NotFound
658+
try:
659+
func = getattr(self, 'show%s'%self.classname)
660+
except AttributeError:
661+
raise NotFound
662+
func()
663+
return
664+
m = nre.match(action)
665+
if m:
666+
self.classname = m.group(1)
667+
try:
668+
func = getattr(self, 'new%s'%self.classname)
669+
except AttributeError:
670+
raise NotFound
671+
func()
672+
return
673+
self.classname = action
674+
try:
675+
self.db.getclass(self.classname)
676+
except KeyError:
677+
raise NotFound
678+
self.list()
672679

673680
def __del__(self):
674681
self.db.close()
@@ -808,6 +815,11 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
808815

809816
#
810817
# $Log: not supported by cvs2svn $
818+
# Revision 1.36 2001/10/21 04:44:50 richard
819+
# bug #473124: UI inconsistency with Link fields.
820+
# This also prompted me to fix a fairly long-standing usability issue -
821+
# that of being able to turn off certain filters.
822+
#
811823
# Revision 1.35 2001/10/21 00:17:54 richard
812824
# CGI interface view customisation section may now be hidden (patch from
813825
# Roch'e Compaan.)

roundup/htmltemplate.py

Lines changed: 31 additions & 8 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.30 2001-10-21 04:44:50 richard Exp $
18+
# $Id: htmltemplate.py,v 1.31 2001-10-21 07:26:35 richard Exp $
1919

2020
import os, re, StringIO, urllib, cgi, errno
2121

@@ -210,11 +210,16 @@ def __call__(self, property, size=None, height=None, showid=0):
210210

211211
#XXX deviates from spec
212212
class Link(Base):
213-
''' for a Link or Multilink property, display the names of the linked
214-
nodes, hyperlinked to the item views on those nodes
215-
for other properties, link to this node with the property as the text
213+
'''For a Link or Multilink property, display the names of the linked
214+
nodes, hyperlinked to the item views on those nodes.
215+
For other properties, link to this node with the property as the
216+
text.
217+
218+
If is_download is true, append the property value to the generated
219+
URL so that the link may be used as a download link and the
220+
downloaded file name is correct.
216221
'''
217-
def __call__(self, property=None, **args):
222+
def __call__(self, property=None, is_download=0):
218223
if not self.nodeid and self.form is None:
219224
return '[Link: not called from item]'
220225
propclass = self.properties[property]
@@ -230,7 +235,11 @@ def __call__(self, property=None, **args):
230235
linkcl = self.db.classes[linkname]
231236
k = linkcl.labelprop()
232237
linkvalue = linkcl.get(value, k)
233-
return '<a href="%s%s">%s</a>'%(linkname, value, linkvalue)
238+
if is_download:
239+
return '<a href="%s%s/%s">%s</a>'%(linkname, value,
240+
linkvalue, linkvalue)
241+
else:
242+
return '<a href="%s%s">%s</a>'%(linkname, value, linkvalue)
234243
if isinstance(propclass, hyperdb.Multilink):
235244
linkname = propclass.classname
236245
linkcl = self.db.classes[linkname]
@@ -239,11 +248,20 @@ def __call__(self, property=None, **args):
239248
l = []
240249
for value in value:
241250
linkvalue = linkcl.get(value, k)
242-
l.append('<a href="%s%s">%s</a>'%(linkname, value, linkvalue))
251+
if is_download:
252+
l.append('<a href="%s%s/%s">%s</a>'%(linkname, value,
253+
linkvalue, linkvalue))
254+
else:
255+
l.append('<a href="%s%s">%s</a>'%(linkname, value,
256+
linkvalue))
243257
return ', '.join(l)
244258
if isinstance(propclass, hyperdb.String):
245259
if value == '': value = '[no %s]'%property.capitalize()
246-
return '<a href="%s%s">%s</a>'%(self.classname, self.nodeid, value)
260+
if is_download:
261+
return '<a href="%s%s/%s">%s</a>'%(self.classname, self.nodeid,
262+
value, value)
263+
else:
264+
return '<a href="%s%s">%s</a>'%(self.classname, self.nodeid, value)
247265

248266
class Count(Base):
249267
''' for a Multilink property, display a count of the number of links in
@@ -815,6 +833,11 @@ def newitem(client, templates, db, classname, form, replace=re.compile(
815833

816834
#
817835
# $Log: not supported by cvs2svn $
836+
# Revision 1.30 2001/10/21 04:44:50 richard
837+
# bug #473124: UI inconsistency with Link fields.
838+
# This also prompted me to fix a fairly long-standing usability issue -
839+
# that of being able to turn off certain filters.
840+
#
818841
# Revision 1.29 2001/10/21 00:17:56 richard
819842
# CGI interface view customisation section may now be hidden (patch from
820843
# Roch'e Compaan.)

roundup/roundupdb.py

Lines changed: 7 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: roundupdb.py,v 1.13 2001-10-21 00:45:15 richard Exp $
18+
# $Id: roundupdb.py,v 1.14 2001-10-21 07:26:35 richard Exp $
1919

2020
import re, os, smtplib, socket
2121

@@ -49,6 +49,9 @@ def uidFromAddress(self, address, create=1):
4949
class Class(hyperdb.Class):
5050
# Overridden methods:
5151
def __init__(self, db, classname, **properties):
52+
if (properties.has_key('creation') or properties.has_key('activity')
53+
or properties.has_key('creator')):
54+
raise ValueError, '"creation", "activity" and "creator" are reserved'
5255
hyperdb.Class.__init__(self, db, classname, **properties)
5356
self.auditors = {'create': [], 'set': [], 'retire': []}
5457
self.reactors = {'create': [], 'set': [], 'retire': []}
@@ -210,9 +213,6 @@ def __init__(self, db, classname, **properties):
210213
properties['nosy'] = hyperdb.Multilink("user")
211214
if not properties.has_key('superseder'):
212215
properties['superseder'] = hyperdb.Multilink(classname)
213-
if (properties.has_key('creation') or properties.has_key('activity')
214-
or properties.has_key('creator')):
215-
raise ValueError, '"creation", "activity" and "creator" are reserved'
216216
Class.__init__(self, db, classname, **properties)
217217

218218
# New methods:
@@ -303,6 +303,9 @@ def email_footer(self, nodeid, msgid):
303303

304304
#
305305
# $Log: not supported by cvs2svn $
306+
# Revision 1.13 2001/10/21 00:45:15 richard
307+
# Added author identification to e-mail messages from roundup.
308+
#
306309
# Revision 1.12 2001/10/04 02:16:15 richard
307310
# Forgot to pass the protected flag down *sigh*.
308311
#

0 commit comments

Comments
 (0)