From a476e0b93c61127540f978a03580983faf911a18 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 14 Oct 2001 10:55:00 +0000 Subject: [PATCH] Handle empty strings in HTML template Link function git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@302 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/cgi_client.py | 13 ++++++++++--- roundup/htmltemplate.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index d4cdaf5..223a786 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.30 2001-10-09 07:38:58 richard Exp $ +# $Id: cgi_client.py,v 1.31 2001-10-14 10:55:00 richard Exp $ import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes import base64, Cookie, time @@ -623,17 +623,19 @@ class Client: except IndexError: raise NotFound try: - getattr(self, 'show%s'%self.classname)() + func = getattr(self, 'show%s'%self.classname) except AttributeError: raise NotFound + func() return m = nre.match(path[0]) if m: self.classname = m.group(1) try: - getattr(self, 'new%s'%self.classname)() + func = getattr(self, 'new%s'%self.classname) except AttributeError: raise NotFound + func() return self.classname = path[0] try: @@ -777,6 +779,11 @@ def parsePropsFromForm(cl, form, nodeid=0): # # $Log: not supported by cvs2svn $ +# Revision 1.30 2001/10/09 07:38:58 richard +# Pushed the base code for the extended schema CGI interface back into the +# code cgi_client module so that future updates will be less painful. +# Also removed a debugging print statement from cgi_client. +# # Revision 1.29 2001/10/09 07:25:59 richard # Added the Password property type. See "pydoc roundup.password" for # implementation details. Have updated some of the documentation too. diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 2bfa2b5..8faff5b 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.25 2001-10-09 07:25:59 richard Exp $ +# $Id: htmltemplate.py,v 1.26 2001-10-14 10:55:00 richard Exp $ import os, re, StringIO, urllib, cgi, errno @@ -213,11 +213,11 @@ class Link(Base): value = self.cl.get(self.nodeid, property) else: if isinstance(propclass, hyperdb.Multilink): value = [] + elif isinstance(propclass, hyperdb.Link): value = None else: value = '' if isinstance(propclass, hyperdb.Link): linkname = propclass.classname - if value is None: - return '[not assigned]' + if value is None: return '[no %s]'%property.capitalize() linkcl = self.db.classes[linkname] k = linkcl.labelprop() linkvalue = linkcl.get(value, k) @@ -226,11 +226,14 @@ class Link(Base): linkname = propclass.classname linkcl = self.db.classes[linkname] k = linkcl.labelprop() + if not value : return '[no %s]'%property.capitalize() l = [] for value in value: linkvalue = linkcl.get(value, k) l.append('%s'%(linkname, value, linkvalue)) return ', '.join(l) + if isinstance(propclass, hyperdb.String): + if value == '': value = '[no %s]'%property.capitalize() return '%s'%(self.classname, self.nodeid, value) class Count(Base): @@ -753,6 +756,10 @@ def newitem(client, templates, db, classname, form, replace=re.compile( # # $Log: not supported by cvs2svn $ +# Revision 1.25 2001/10/09 07:25:59 richard +# Added the Password property type. See "pydoc roundup.password" for +# implementation details. Have updated some of the documentation too. +# # Revision 1.24 2001/09/27 06:45:58 richard # *gak* ... xmp is Old Skool apparently. Am using pre again by have the option # on the plain() template function to escape the text for HTML. -- 2.30.2