Skip to content

Commit 46b4bb3

Browse files
author
Richard Jones
committed
The "type" parameter is supposed to be optional
1 parent ffe1bdc commit 46b4bb3

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

roundup/backends/back_anydbm.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.168 2004-07-27 01:59:28 richard Exp $
18+
#$Id: back_anydbm.py,v 1.169 2004-07-27 04:28:39 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -2118,19 +2118,23 @@ def set(self, itemid, **propvalues):
21182118
content = propvalues['content']
21192119
del propvalues['content']
21202120

2121-
# do the database create
2121+
# do the database update
21222122
propvalues = self.set_inner(itemid, **propvalues)
21232123

21242124
# do content?
21252125
if content:
21262126
# store and index
21272127
self.db.storefile(self.classname, itemid, None, content)
2128-
mime_type = propvalues.get('type', self.get(itemid, 'type'))
2129-
if not mime_type:
2128+
if self.getprops().has_key('type'):
2129+
mime_type = propvalues.get('type', self.get(itemid, 'type',
2130+
self.default_mime_type))
2131+
else:
21302132
mime_type = self.default_mime_type
21312133
self.db.indexer.add_text((self.classname, itemid, 'content'),
21322134
content, mime_type)
21332135

2136+
propvalues['content'] = content
2137+
21342138
# fire reactors
21352139
self.fireReactors('set', itemid, oldvalues)
21362140
return propvalues

roundup/backends/rdbms_common.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.125 2004-07-27 01:18:25 richard Exp $
1+
# $Id: rdbms_common.py,v 1.126 2004-07-27 04:28:39 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2562,12 +2562,16 @@ def set(self, itemid, **propvalues):
25622562
if content:
25632563
# store and index
25642564
self.db.storefile(self.classname, itemid, None, content)
2565-
mime_type = propvalues.get('type', self.get(itemid, 'type'))
2566-
if not mime_type:
2565+
if self.getprops().has_key('type'):
2566+
mime_type = propvalues.get('type', self.get(itemid, 'type',
2567+
self.default_mime_type))
2568+
else:
25672569
mime_type = self.default_mime_type
25682570
self.db.indexer.add_text((self.classname, itemid, 'content'),
25692571
content, mime_type)
25702572

2573+
propvalues['content'] = content
2574+
25712575
# fire reactors
25722576
self.fireReactors('set', itemid, oldvalues)
25732577
return propvalues

roundup/cgi/templating.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,14 @@ def next(self):
22522252
return Batch(self.client, self._sequence, self._size,
22532253
self.end - self.overlap, 0, self.orphan, self.overlap)
22542254

2255+
class TemplatingUtil:
2256+
def __init__(self, utils, callable):
2257+
self.utils = utils
2258+
self.callable = callable
2259+
def __call__(self, *args, **kw):
2260+
args = (self.utils,)+args
2261+
return self.callable(*args, **kw)
2262+
22552263
class TemplatingUtils:
22562264
''' Utilities for templating
22572265
'''
@@ -2269,4 +2277,13 @@ def html_quote(self, html):
22692277
'''HTML-quote the supplied text.'''
22702278
return cgi.escape(url)
22712279

2280+
def __getattr__(self, name):
2281+
'''Try the tracker's templating_utils.'''
2282+
if not hasattr(self.client.instance, 'templating_utils'):
2283+
# backwards-compatibility
2284+
raise AttributeError, name
2285+
if not self.client.instance.templating_utils.has_key(name):
2286+
raise AttributeError, name
2287+
return TemplatingUtil(self, self.client.instance.templating_utils[name])
2288+
22722289
# vim: set et sts=4 sw=4 :

0 commit comments

Comments
 (0)