summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d101b43)
raw | patch | inline | side by side (parent: d101b43)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 29 Jul 2001 05:36:14 +0000 (05:36 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 29 Jul 2001 05:36:14 +0000 (05:36 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@129 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/htmltemplate.py | patch | blob | history | |
roundup/hyperdb.py | patch | blob | history |
index f39a72bc80daf69024f5a22d81069c1aed1fa7bf..b7edbf45d732f5f4c5a7491d6d1051d5d4134110 100644 (file)
--- a/roundup/htmltemplate.py
+++ b/roundup/htmltemplate.py
-# $Id: htmltemplate.py,v 1.6 2001-07-29 04:06:42 richard Exp $
+# $Id: htmltemplate.py,v 1.7 2001-07-29 05:36:14 richard Exp $
import os, re, StringIO, urllib, cgi, errno
value = str(value)
elif propclass.isLinkType:
linkcl = self.db.classes[propclass.classname]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
if value: value = str(linkcl.get(value, k))
else: value = '[unselected]'
elif propclass.isMultilinkType:
linkcl = self.db.classes[propclass.classname]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
value = ', '.join([linkcl.get(i, k) for i in value])
else:
s = 'Plain: bad propclass "%s"'%propclass
elif propclass.isLinkType:
linkcl = self.db.classes[propclass.classname]
l = ['<select name="%s">'%property]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
for optionid in linkcl.list():
option = linkcl.get(optionid, k)
s = ''
list = linkcl.list()
height = height or min(len(list), 7)
l = ['<select multiple name="%s" size="%s">'%(property, height)]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
for optionid in list:
option = linkcl.get(optionid, k)
s = ''
if propclass.isLinkType:
linkcl = self.db.classes[propclass.classname]
l = ['<select name="%s">'%property]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
for optionid in linkcl.list():
option = linkcl.get(optionid, k)
s = ''
list = linkcl.list()
height = height or min(len(list), 7)
l = ['<select multiple name="%s" size="%s">'%(property, height)]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
for optionid in list:
option = linkcl.get(optionid, k)
s = ''
if value is None:
return '[not assigned]'
linkcl = self.db.classes[propclass.classname]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
linkvalue = linkcl.get(value, k)
return '<a href="%s%s">%s</a>'%(linkcl, value, linkvalue)
if propclass.isMultilinkType:
linkcl = self.db.classes[propclass.classname]
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
l = []
for value in value:
linkvalue = linkcl.get(value, k)
if propclass.isLinkType or propclass.isMultilinkType:
linkcl = self.db.classes[propclass.classname]
l = []
- k = linkcl.getkey()
- # if the linked-to class doesn't have a key property, then try
- # 'name', then 'title' and then just use a random one.
- if not k:
- linkprops = linkcl.getprops()
- if linkprops.has_key('name'):
- k = 'name'
- elif linkprops.has_key('title'):
- k = 'title'
- else:
- k = linkprops.keys()[0]
+ k = linkcl.labelprop()
for optionid in linkcl.list():
option = linkcl.get(optionid, k)
if optionid in value:
#
# $Log: not supported by cvs2svn $
+# Revision 1.6 2001/07/29 04:06:42 richard
+# Fixed problem in link display when Link value is None.
+#
# Revision 1.5 2001/07/28 08:17:09 richard
# fixed use of stylesheet
#
diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py
index 4c13318efb13dac271743e2cf371d39f3c1874b6..2a09c3c96a73ed11a6bd65164d265f9ccc17ee85 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
-# $Id: hyperdb.py,v 1.5 2001-07-29 04:05:37 richard Exp $
+# $Id: hyperdb.py,v 1.6 2001-07-29 05:36:14 richard Exp $
# standard python modules
import cPickle, re, string
"""Return the name of the key property for this class or None."""
return self.key
+ def labelprop(self, nodeid):
+ ''' Return the property name for a label for the given node.
+
+ This method attempts to generate a consistent label for the node.
+ It tries the following in order:
+ 1. key property
+ 2. "name" property
+ 3. "title" property
+ 4. first property from the sorted property name list
+ '''
+ k = self.getkey()
+ if k:
+ return k
+ props = self.getprops()
+ if props.has_key('name'):
+ return 'name'
+ elif props.has_key('title'):
+ return 'title'
+ props = props.keys()
+ props.sort()
+ return props[0]
+
# TODO: set up a separate index db file for this? profile?
def lookup(self, keyvalue):
"""Locate a particular node by its key property and return its id.
#
# $Log: not supported by cvs2svn $
+# Revision 1.5 2001/07/29 04:05:37 richard
+# Added the fabricated property "id".
+#
# Revision 1.4 2001/07/27 06:25:35 richard
# Fixed some of the exceptions so they're the right type.
# Removed the str()-ification of node ids so we don't mask oopsy errors any