diff roundup/cgi/templating.py @ 2180:58b6d1747973

Web interface tweaks. - added a favicon - added url_quote and html_quote methods to the utils object - added isset method to HTMLProperty - added "download_url" method to generate a correctly quoted URL for file download links [SF#927745]
author Richard Jones <richard@users.sourceforge.net>
date Mon, 05 Apr 2004 00:51:45 +0000
parents 0def552122af
children a993c3dcac9b
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Mon Apr 05 00:51:00 2004 +0000
+++ b/roundup/cgi/templating.py	Mon Apr 05 00:51:45 2004 +0000
@@ -1,5 +1,15 @@
 """Implements the API used in the HTML templating for the web interface.
 """
+
+todo = '''
+- Most methods should have a "default" arg to supply a value 
+  when none appears in the hyperdb or request. 
+- Multilink property additions: change_note and new_upload
+- Add class.find() too
+- NumberHTMLProperty should support numeric operations
+- HTMLProperty should have an isset() method
+'''
+
 __docformat__ = 'restructuredtext'
 
 from __future__ import nested_scopes
@@ -900,6 +910,15 @@
         # use our fabricated request
         return pt.render(self._client, req.classname, req)
 
+    def download_url(self):
+        ''' Assume that this item is a FileClass and that it has a name
+        and content. Construct a URL for the download of the content.
+        '''
+        name = self._klass.get(self._nodeid, 'name')
+        url = '%s%s/%s'%(self._classname, self._nodeid, name)
+        return urllib.quote(url)
+
+
 class HTMLUserPermission:
 
     def is_edit_ok(self):
@@ -995,6 +1014,10 @@
             return cmp(self._value, other._value)
         return cmp(self._value, other)
 
+    def isset(self):
+        '''Is my _value None?'''
+        return self._value is None
+
     def is_edit_ok(self):
         ''' Is the user allowed to Edit the current class?
         '''
@@ -1527,6 +1550,10 @@
         '''
         return str(value) in self._value
 
+    def isset(self):
+        '''Is my _value []?'''
+        return self._value == []
+
     def reverse(self):
         ''' return the list in reverse order
         '''
@@ -2084,3 +2111,11 @@
         return Batch(self.client, sequence, size, start, end, orphan,
             overlap)
 
+    def url_quote(self, url):
+        '''URL-quote the supplied text.'''
+        return urllib.quote(url)
+
+    def html_quote(self, html):
+        '''HTML-quote the supplied text.'''
+        return cgi.escape(url)
+

Roundup Issue Tracker: http://roundup-tracker.org/