index 2425f6810a2125fdf526c21b482d24c33915927f..1de56e1ce1d42b1503959af6015915b1961f6203 100644 (file)
if self._v_errors:
raise PageTemplate.PTRuntimeError, \
- 'Page Template %s has errors.' % self.id
+ 'Page Template %s has errors.'%self.id
# figure the context
classname = classname or client.classname
klass = HTMLUser
else:
klass = HTMLItem
- l = [klass(self._client, self.classname, x) for x in self._klass.list()]
+
+ # get the list and sort it nicely
+ l = self._klass.list()
+ sortfunc = make_sort_function(self._db, self.classname)
+ l.sort(sortfunc)
+
+ l = [klass(self._client, self.classname, x) for x in l]
return l
def csv(self):
def __getitem__(self, item):
''' return an HTMLProperty instance
'''
- #print 'HTMLItem.getitem', (self, item)
+ #print 'HTMLItem.getitem', (self, item)
if item == 'id':
return self._nodeid
return _('*encrypted*')
def field(self, size = 30):
- ''' Render a form edit field for the property
+ ''' Render a form edit field for the property.
'''
return '<input type="password" name="%s" size="%s">'%(self._name, size)
+ def confirm(self, size = 30):
+ ''' Render a second form edit field for the property, used for
+ confirmation that the user typed the password correctly. Generates
+ a field with name "name:confirm".
+ '''
+ return '<input type="password" name="%s:confirm" size="%s">'%(
+ self._name, size)
+
class NumberHTMLProperty(HTMLProperty):
def plain(self):
''' Render a "plain" representation of the property
s = ''
l.append(_('<option %svalue="-1">- no selection -</option>')%s)
for optionid in options:
- option = linkcl.get(optionid, k)
+ # get the option value, and if it's None use an empty string
+ option = linkcl.get(optionid, k) or ''
+
+ # figure if this option is selected
s = ''
if optionid == self._value:
s = 'selected '
+
+ # figure the label
if showid:
lab = '%s%s: %s'%(self._prop.classname, optionid, option)
else:
lab = option
+
+ # truncate if it's too long
if size is not None and len(lab) > size:
lab = lab[:size-3] + '...'
+
+ # and generate
lab = cgi.escape(lab)
l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab))
l.append('</select>')
# sort function
sortfunc = make_sort_function(self._db, self._prop.classname)
- # force the value to be a single choice
- if isinstance(value, type('')):
- value = value[0]
linkcl = self._db.getclass(self._prop.classname)
l = ['<select name="%s">'%self._name]
k = linkcl.labelprop(1)
sort_on = ('+', linkcl.labelprop())
options = linkcl.filter(None, conditions, sort_on, (None, None))
for optionid in options:
- option = linkcl.get(optionid, k)
+ # get the option value, and if it's None use an empty string
+ option = linkcl.get(optionid, k) or ''
+
+ # figure if this option is selected
s = ''
if value in [optionid, option]:
s = 'selected '
+
+ # figure the label
if showid:
lab = '%s%s: %s'%(self._prop.classname, optionid, option)
else:
lab = option
+
+ # truncate if it's too long
if size is not None and len(lab) > size:
lab = lab[:size-3] + '...'
if additional:
for propname in additional:
m.append(linkcl.get(optionid, propname))
lab = lab + ' (%s)'%', '.join(map(str, m))
+
+ # and generate
lab = cgi.escape(lab)
l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab))
l.append('</select>')
l = ['<select multiple name="%s" size="%s">'%(self._name, height)]
k = linkcl.labelprop(1)
for optionid in options:
- option = linkcl.get(optionid, k)
+ # get the option value, and if it's None use an empty string
+ option = linkcl.get(optionid, k) or ''
+
+ # figure if this option is selected
s = ''
if optionid in value or option in value:
s = 'selected '
+
+ # figure the label
if showid:
lab = '%s%s: %s'%(self._prop.classname, optionid, option)
else:
lab = option
+ # truncate if it's too long
if size is not None and len(lab) > size:
lab = lab[:size-3] + '...'
if additional:
for propname in additional:
m.append(linkcl.get(optionid, propname))
lab = lab + ' (%s)'%', '.join(m)
+
+ # and generate
lab = cgi.escape(lab)
l.append('<option %svalue="%s">%s</option>'%(s, optionid,
lab))
"form" the CGI form as a cgi.FieldStorage
"env" the CGI environment variables
- "url" the current URL path for this request
"base" the base URL for this instance
"user" a HTMLUser instance for this user
"classname" the current classname (possibly None)
self.form = client.form
self.env = client.env
self.base = client.base
- self.url = client.url
self.user = HTMLUser(client, 'user', client.userid)
# store the current class name and action
d['env'] = e
return '''
form: %(form)s
-url: %(url)r
base: %(base)r
classname: %(classname)r
template: %(template)r