X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=roundup%2Fhtmltemplate.py;h=3d9d69e70b3933f21ab964327230d44135fe302f;hb=6bbc898fcaf4c040ef5a5883949157ca9bef9db0;hp=1ce86ca759890ee3297bce19362493ed7122a69d;hpb=fb1c4f5da7d5606485d684528a2eaf74331d8a15;p=roundup.git diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 1ce86ca..3d9d69e 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -1,4 +1,21 @@ -# $Id: htmltemplate.py,v 1.15 2001-07-30 08:12:17 richard Exp $ +# +# Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) +# This module is free software, and you may redistribute it and/or modify +# under the same terms as Python, so long as this copyright message and +# disclaimer are retained in their original form. +# +# IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR +# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING +# OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, +# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" +# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, +# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +# +# $Id: htmltemplate.py,v 1.21 2001-08-16 07:34:59 richard Exp $ import os, re, StringIO, urllib, cgi, errno @@ -31,21 +48,21 @@ class Plain(Base): value = self.cl.get(self.nodeid, property) else: # TODO: pull the value from the form - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = '' - if propclass.isStringType: + if isinstance(propclass, hyperdb.String): if value is None: value = '' else: value = str(value) - elif propclass.isDateType: + elif isinstance(propclass, hyperdb.Date): value = str(value) - elif propclass.isIntervalType: + elif isinstance(propclass, hyperdb.Interval): value = str(value) - elif propclass.isLinkType: + elif isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() if value: value = str(linkcl.get(value, k)) else: value = '[unselected]' - elif propclass.isMultilinkType: + elif isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() value = ', '.join([linkcl.get(i, k) for i in value]) @@ -66,19 +83,20 @@ class Field(Base): # TODO: remove this from the code ... it's only here for # handling schema changes, and they should be handled outside # of this code... - if propclass.isMultilinkType and value is None: + if isinstance(propclass, hyperdb.Multilink) and value is None: value = [] elif self.filterspec is not None: - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): value = self.filterspec.get(property, []) else: value = self.filterspec.get(property, '') else: # TODO: pull the value from the form - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = '' - if (propclass.isStringType or propclass.isDateType or - propclass.isIntervalType): + if (isinstance(propclass, hyperdb.String) or + isinstance(propclass, hyperdb.Date) or + isinstance(propclass, hyperdb.Interval)): size = size or 30 if value is None: value = '' @@ -86,7 +104,7 @@ class Field(Base): value = cgi.escape(value) value = '"'.join(value.split('"')) s = ''%(property, value, size) - elif propclass.isLinkType: + elif isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] l = ['') s = '\n'.join(l) - elif propclass.isMultilinkType: + elif isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] list = linkcl.list() height = height or min(len(list), 7) @@ -137,9 +155,9 @@ class Menu(Base): value = self.cl.get(self.nodeid, property) else: # TODO: pull the value from the form - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = None - if propclass.isLinkType: + if isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] l = ['') return '\n'.join(l) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] list = linkcl.list() height = height or min(len(list), 7) @@ -186,16 +204,16 @@ class Link(Base): if self.nodeid: value = self.cl.get(self.nodeid, property) else: - if propclass.isMultilinkType: value = [] + if isinstance(propclass, hyperdb.Multilink): value = [] else: value = '' - if propclass.isLinkType: + if isinstance(propclass, hyperdb.Link): if value is None: return '[not assigned]' linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() linkvalue = linkcl.get(value, k) return '%s'%(linkcl, value, linkvalue) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() l = [] @@ -214,7 +232,7 @@ class Count(Base): return '[Count: not called from item]' propclass = self.properties[property] value = self.cl.get(self.nodeid, property) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): return str(len(value)) return '[Count: not a Multilink]' @@ -229,7 +247,7 @@ class Reldate(Base): if not self.nodeid and self.form is None: return '[Reldate: not called from item]' propclass = self.properties[property] - if not propclass.isDateType: + if isinstance(not propclass, hyperdb.Date): return '[Reldate: not a Date]' if self.nodeid: value = self.cl.get(self.nodeid, property) @@ -254,11 +272,11 @@ class Download(Base): return '[Download: not called from item]' propclass = self.properties[property] value = self.cl.get(self.nodeid, property) - if propclass.isLinkType: + if isinstance(propclass, hyperdb.Link): linkcl = self.db.classes[propclass.classname] linkvalue = linkcl.get(value, k) return '%s'%(linkcl, value, linkvalue) - if propclass.isMultilinkType: + if isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] l = [] for value in value: @@ -280,7 +298,8 @@ class Checklist(Base): value = self.filterspec.get(property, []) else: value = [] - if propclass.isLinkType or propclass.isMultilinkType: + if (isinstance(propclass, hyperdb.Link) or + isinstance(propclass, hyperdb.Multilink)): linkcl = self.db.classes[propclass.classname] l = [] k = linkcl.labelprop() @@ -291,7 +310,7 @@ class Checklist(Base): else: checked = '' l.append('%s:'%( - option, checked, propclass.classname, option)) + option, checked, property, option)) return '\n'.join(l) return '[Checklist: not a link]' @@ -311,7 +330,7 @@ class List(Base): ''' def __call__(self, property, **args): propclass = self.properties[property] - if not propclass.isMultilinkType: + if isinstance(not propclass, hyperdb.Multilink): return '[List: not a Multilink]' fp = StringIO.StringIO() args['show_display_form'] = 0 @@ -368,7 +387,7 @@ class IndexTemplateReplace: r'(([^>]+)">(?P.+?))|' r'(?P[^"]+)">))', re.I|re.S)): return replace.sub(self, text) - + def __call__(self, m, filter=None, columns=None, sort=None, group=None): if m.group('name'): if m.group('name') in self.props: @@ -486,18 +505,18 @@ def index(client, templates, db, classname, filterspec={}, filter=[], columns = l # now display the index section - w('') - w('') + w('
\n') + w('\n') for name in columns: cname = name.capitalize() if show_display_form: anchor = "%s?%s"%(classname, sortby(name, columns, filter, sort, group, filterspec)) - w(''%( + w('\n'%( anchor, cname)) else: - w(''%cname) - w('') + w('\n'%cname) + w('\n') # this stuff is used for group headings - optimise the group names old_group = None @@ -519,7 +538,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[], l = [] for name in group_names: prop = properties[name] - if prop.isLinkType: + if isinstance(prop, hyperdb.Link): group_cl = db.classes[prop.classname] key = group_cl.getkey() value = cl.get(nodeid, name) @@ -527,7 +546,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[], l.append('[unselected %s]'%prop.classname) else: l.append(group_cl.get(cl.get(nodeid, name), key)) - elif prop.isMultilinkType: + elif isinstance(prop, hyperdb.Multilink): group_cl = db.classes[prop.classname] key = group_cl.getkey() for value in cl.get(nodeid, name): @@ -556,49 +575,49 @@ def index(client, templates, db, classname, filterspec={}, filter=[], # now add in the filter/columns/group/etc config table form w('

') - w('

%s%s%s
%s
') + w('
\n') names = [] for name in cl.getprops().keys(): if name in all_filters or name in all_columns: names.append(name) w('') - w(''% + w('\n'% (len(names)+1)) w('') for name in names: w(''%name.capitalize()) - w('') + w('\n') # filter if all_filters: - w('') + w('\n') for name in names: if name not in all_filters: w('') continue if name in filter: checked=' checked' else: checked='' - w(''%(name, - checked)) - w('') + w('\n'%( + name, checked)) + w('\n') # columns if all_columns: - w('') + w('\n') for name in names: if name not in all_columns: w('') continue if name in columns: checked=' checked' else: checked='' - w(''%( + w('\n'%( name, checked)) - w('') + w('\n') # group - w('') + w('\n') for name in names: prop = properties[name] if name not in all_columns: @@ -606,16 +625,16 @@ def index(client, templates, db, classname, filterspec={}, filter=[], continue if name in group: checked=' checked' else: checked='' - w(''%( + w('\n'%( name, checked)) - w('') + w('\n') w('') w('') - w('
View customisation...
View customisation...
 %s
Filters
Filters ') - w('
\n') + w('
Columns
Columns ') - w('\n') + w('
Grouping
Grouping') - w('\n') + w('
 '%len(names)) - w('
') - w('') + w('\n') + w('\n') + w('\n') # @@ -723,6 +742,26 @@ def newitem(client, templates, db, classname, form, replace=re.compile( # # $Log: not supported by cvs2svn $ +# Revision 1.20 2001/08/15 23:43:18 richard +# Fixed some isFooTypes that I missed. +# Refactored some code in the CGI code. +# +# Revision 1.19 2001/08/12 06:32:36 richard +# using isinstance(blah, Foo) now instead of isFooType +# +# Revision 1.18 2001/08/07 00:24:42 richard +# stupid typo +# +# Revision 1.17 2001/08/07 00:15:51 richard +# Added the copyright/license notice to (nearly) all files at request of +# Bizar Software. +# +# Revision 1.16 2001/08/01 03:52:23 richard +# Checklist was using wrong name. +# +# Revision 1.15 2001/07/30 08:12:17 richard +# Added time logging and file uploading to the templates. +# # Revision 1.14 2001/07/30 06:17:45 richard # Features: # . Added ability for cgi newblah forms to indicate that the new node