Index: roundup-src/roundup/cgi/templating.py
===================================================================
--- roundup-src/roundup/cgi/templating.py (revision 83077)
+++ roundup-src/roundup/cgi/templating.py (working copy)
@@ -1325,7 +1325,42 @@
)''', re.X | re.I)
protocol_re = re.compile('^(ht|f)tp(s?)://', re.I)
- def _hyper_repl_item(self,match,replacement):
+
+
+ def _hyper_repl(self, match):
+ if match.group('url'):
+ return self._hyper_repl_url(match, '%s%s')
+ elif match.group('email'):
+ return self._hyper_repl_email(match, '%s')
+ elif len(match.group('id')) < 10:
+ return self._hyper_repl_item(match,
+ '%(item)s')
+ else:
+ # just return the matched text
+ return match.group(0)
+
+ def _hyper_repl_url(self, match, replacement):
+ u = s = match.group('url')
+ if not self.protocol_re.search(s):
+ u = 'http://' + s
+ if s.endswith('>'):
+ # catch an escaped ">" at the end of the URL
+ u = s = s[:-4]
+ e = '>'
+ elif s.count('(') != s.count(')'):
+ # don't include extraneous ')' in the link
+ pos = s.rfind(')')
+ e = s[pos:]
+ u = s = s[:pos]
+ else:
+ e = ''
+ return replacement % (u, s, e)
+
+ def _hyper_repl_email(self, match, replacement):
+ s = match.group('email')
+ return replacement % (s, s)
+
+ def _hyper_repl_item(self, match, replacement):
item = match.group('item')
cls = match.group('class').lower()
id = match.group('id')
@@ -1338,32 +1373,6 @@
except KeyError:
return item
- def _hyper_repl(self, match):
- if match.group('url'):
- u = s = match.group('url')
- if not self.protocol_re.search(s):
- u = 'http://' + s
- if s.endswith('>'):
- # catch an escaped ">" at the end of the URL
- u = s = s[:-4]
- e = '>'
- elif s.count('(') != s.count(')'):
- # don't include extraneous ')' in the link
- pos = s.rfind(')')
- e = s[pos:]
- u = s = s[:pos]
- else:
- e = ''
- return '%s%s' % (u, s, e)
- elif match.group('email'):
- s = match.group('email')
- return '%s' % (s, s)
- elif len(match.group('id')) < 10:
- return self._hyper_repl_item(match,
- '%(item)s')
- else:
- # just return the matched text
- return match.group(0)
def _hyper_repl_rst(self, match):
if match.group('url'):
@@ -2259,8 +2268,9 @@
l.append('')
return '\n'.join(l)
+
# set the propclasses for HTMLItem
-propclasses = (
+propclasses = [
(hyperdb.String, StringHTMLProperty),
(hyperdb.Number, NumberHTMLProperty),
(hyperdb.Boolean, BooleanHTMLProperty),
@@ -2269,8 +2279,18 @@
(hyperdb.Password, PasswordHTMLProperty),
(hyperdb.Link, LinkHTMLProperty),
(hyperdb.Multilink, MultilinkHTMLProperty),
-)
+]
+def register_propclass(prop, cls):
+ for index,propclass in enumerate(propclasses):
+ p, c = propclass
+ if prop == p:
+ propclasses[index] = (prop, cls)
+ break
+ else:
+ propclasses.append((prop, cls))
+
+
def make_sort_function(db, classname, sort_on=None):
"""Make a sort function for a given class
"""