changeset 2640:b01eca163779

The "type" parameter is supposed to be optional
author Richard Jones <richard@users.sourceforge.net>
date Tue, 27 Jul 2004 04:28:39 +0000
parents 75d410d11a20
children 744f16fde4b2
files roundup/backends/back_anydbm.py roundup/backends/rdbms_common.py roundup/cgi/templating.py
diffstat 3 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Tue Jul 27 02:34:14 2004 +0000
+++ b/roundup/backends/back_anydbm.py	Tue Jul 27 04:28:39 2004 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.168 2004-07-27 01:59:28 richard Exp $
+#$Id: back_anydbm.py,v 1.169 2004-07-27 04:28:39 richard Exp $
 '''This module defines a backend that saves the hyperdatabase in a
 database chosen by anydbm. It is guaranteed to always be available in python
 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -2118,19 +2118,23 @@
             content = propvalues['content']
             del propvalues['content']
 
-        # do the database create
+        # do the database update
         propvalues = self.set_inner(itemid, **propvalues)
 
         # do content?
         if content:
             # store and index
             self.db.storefile(self.classname, itemid, None, content)
-            mime_type = propvalues.get('type', self.get(itemid, 'type'))
-            if not mime_type:
+            if self.getprops().has_key('type'):
+                mime_type = propvalues.get('type', self.get(itemid, 'type',
+                    self.default_mime_type))
+            else:
                 mime_type = self.default_mime_type
             self.db.indexer.add_text((self.classname, itemid, 'content'),
                 content, mime_type)
 
+            propvalues['content'] = content
+
         # fire reactors
         self.fireReactors('set', itemid, oldvalues)
         return propvalues
--- a/roundup/backends/rdbms_common.py	Tue Jul 27 02:34:14 2004 +0000
+++ b/roundup/backends/rdbms_common.py	Tue Jul 27 04:28:39 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.125 2004-07-27 01:18:25 richard Exp $
+# $Id: rdbms_common.py,v 1.126 2004-07-27 04:28:39 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -2562,12 +2562,16 @@
         if content:
             # store and index
             self.db.storefile(self.classname, itemid, None, content)
-            mime_type = propvalues.get('type', self.get(itemid, 'type'))
-            if not mime_type:
+            if self.getprops().has_key('type'):
+                mime_type = propvalues.get('type', self.get(itemid, 'type',
+                    self.default_mime_type))
+            else:
                 mime_type = self.default_mime_type
             self.db.indexer.add_text((self.classname, itemid, 'content'),
                 content, mime_type)
 
+            propvalues['content'] = content
+
         # fire reactors
         self.fireReactors('set', itemid, oldvalues)
         return propvalues
--- a/roundup/cgi/templating.py	Tue Jul 27 02:34:14 2004 +0000
+++ b/roundup/cgi/templating.py	Tue Jul 27 04:28:39 2004 +0000
@@ -2252,6 +2252,14 @@
         return Batch(self.client, self._sequence, self._size,
             self.end - self.overlap, 0, self.orphan, self.overlap)
 
+class TemplatingUtil:
+    def __init__(self, utils, callable):
+        self.utils = utils
+        self.callable = callable
+    def __call__(self, *args, **kw):
+        args = (self.utils,)+args
+        return self.callable(*args, **kw)
+
 class TemplatingUtils:
     ''' Utilities for templating
     '''
@@ -2269,4 +2277,13 @@
         '''HTML-quote the supplied text.'''
         return cgi.escape(url)
 
+    def __getattr__(self, name):
+        '''Try the tracker's templating_utils.'''
+        if not hasattr(self.client.instance, 'templating_utils'):
+            # backwards-compatibility
+            raise AttributeError, name
+        if not self.client.instance.templating_utils.has_key(name):
+            raise AttributeError, name
+        return TemplatingUtil(self, self.client.instance.templating_utils[name])
+
 # vim: set et sts=4 sw=4 :

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