Skip to content

Commit 98c9e15

Browse files
author
Richard Jones
committed
Handle empty strings in HTML template Link function
1 parent 052d42e commit 98c9e15

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

roundup/cgi_client.py

Lines changed: 10 additions & 3 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.30 2001-10-09 07:38:58 richard Exp $
18+
# $Id: cgi_client.py,v 1.31 2001-10-14 10:55:00 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
2121
import base64, Cookie, time
@@ -623,17 +623,19 @@ def main(self, dre=re.compile(r'([^\d]+)(\d+)'),
623623
except IndexError:
624624
raise NotFound
625625
try:
626-
getattr(self, 'show%s'%self.classname)()
626+
func = getattr(self, 'show%s'%self.classname)
627627
except AttributeError:
628628
raise NotFound
629+
func()
629630
return
630631
m = nre.match(path[0])
631632
if m:
632633
self.classname = m.group(1)
633634
try:
634-
getattr(self, 'new%s'%self.classname)()
635+
func = getattr(self, 'new%s'%self.classname)
635636
except AttributeError:
636637
raise NotFound
638+
func()
637639
return
638640
self.classname = path[0]
639641
try:
@@ -777,6 +779,11 @@ def parsePropsFromForm(cl, form, nodeid=0):
777779

778780
#
779781
# $Log: not supported by cvs2svn $
782+
# Revision 1.30 2001/10/09 07:38:58 richard
783+
# Pushed the base code for the extended schema CGI interface back into the
784+
# code cgi_client module so that future updates will be less painful.
785+
# Also removed a debugging print statement from cgi_client.
786+
#
780787
# Revision 1.29 2001/10/09 07:25:59 richard
781788
# Added the Password property type. See "pydoc roundup.password" for
782789
# implementation details. Have updated some of the documentation too.

roundup/htmltemplate.py

Lines changed: 10 additions & 3 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.25 2001-10-09 07:25:59 richard Exp $
18+
# $Id: htmltemplate.py,v 1.26 2001-10-14 10:55:00 richard Exp $
1919

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

@@ -213,11 +213,11 @@ def __call__(self, property=None, **args):
213213
value = self.cl.get(self.nodeid, property)
214214
else:
215215
if isinstance(propclass, hyperdb.Multilink): value = []
216+
elif isinstance(propclass, hyperdb.Link): value = None
216217
else: value = ''
217218
if isinstance(propclass, hyperdb.Link):
218219
linkname = propclass.classname
219-
if value is None:
220-
return '[not assigned]'
220+
if value is None: return '[no %s]'%property.capitalize()
221221
linkcl = self.db.classes[linkname]
222222
k = linkcl.labelprop()
223223
linkvalue = linkcl.get(value, k)
@@ -226,11 +226,14 @@ def __call__(self, property=None, **args):
226226
linkname = propclass.classname
227227
linkcl = self.db.classes[linkname]
228228
k = linkcl.labelprop()
229+
if not value : return '[no %s]'%property.capitalize()
229230
l = []
230231
for value in value:
231232
linkvalue = linkcl.get(value, k)
232233
l.append('<a href="%s%s">%s</a>'%(linkname, value, linkvalue))
233234
return ', '.join(l)
235+
if isinstance(propclass, hyperdb.String):
236+
if value == '': value = '[no %s]'%property.capitalize()
234237
return '<a href="%s%s">%s</a>'%(self.classname, self.nodeid, value)
235238

236239
class Count(Base):
@@ -753,6 +756,10 @@ def newitem(client, templates, db, classname, form, replace=re.compile(
753756

754757
#
755758
# $Log: not supported by cvs2svn $
759+
# Revision 1.25 2001/10/09 07:25:59 richard
760+
# Added the Password property type. See "pydoc roundup.password" for
761+
# implementation details. Have updated some of the documentation too.
762+
#
756763
# Revision 1.24 2001/09/27 06:45:58 richard
757764
# *gak* ... xmp is Old Skool apparently. Am using pre again by have the option
758765
# on the plain() template function to escape the text for HTML.

0 commit comments

Comments
 (0)