Skip to content

Commit 84fb890

Browse files
author
Richard Jones
committed
various fixes
1 parent 67cabb8 commit 84fb890

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

roundup/backends/back_anydbm.py

Lines changed: 7 additions & 6 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.178 2004-11-25 22:59:17 richard Exp $
18+
#$Id: back_anydbm.py,v 1.179 2004-11-25 23:53:31 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
@@ -2147,10 +2147,10 @@ def set(self, itemid, **propvalues):
21472147
if content:
21482148
# store and index
21492149
self.db.storefile(self.classname, itemid, None, content)
2150+
mime_type = None
21502151
if self.getprops().has_key('type'):
2151-
mime_type = propvalues.get('type', self.get(itemid, 'type',
2152-
self.default_mime_type))
2153-
else:
2152+
mime_type = propvalues.get('type', self.get(itemid, 'type'))
2153+
if not mime_type:
21542154
mime_type = self.default_mime_type
21552155
self.db.indexer.add_text((self.classname, itemid, 'content'),
21562156
content, mime_type)
@@ -2179,9 +2179,10 @@ def index(self, nodeid):
21792179
Pass on the content-type property for the content property.
21802180
'''
21812181
Class.index(self, nodeid)
2182-
try:
2182+
mime_type = None
2183+
if self.getprops().has_key('type'):
21832184
mime_type = self.get(nodeid, 'type', self.default_mime_type)
2184-
except KeyError:
2185+
if not mime_type:
21852186
mime_type = self.default_mime_type
21862187
self.db.indexer.add_text((self.classname, nodeid, 'content'),
21872188
str(self.get(nodeid, 'content')), mime_type)

roundup/backends/blobfiles.py

Lines changed: 4 additions & 3 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: blobfiles.py,v 1.16 2004-11-25 22:51:06 richard Exp $
18+
#$Id: blobfiles.py,v 1.17 2004-11-25 23:53:31 richard Exp $
1919
'''This module exports file storage for roundup backends.
2020
Files are stored into a directory hierarchy.
2121
'''
@@ -146,7 +146,8 @@ def rollbackStoreFile(self, classname, nodeid, property, **databases):
146146
'''
147147
# determine the name of the file to delete
148148
name = self.filename(classname, nodeid, property)
149-
if os.path.exists(name+".tmp"):
150-
os.remove(name+".tmp")
149+
if not name.endswith('.tmp'):
150+
name += '.tmp'
151+
os.remove(name)
151152

152153
# vim: set filetype=python ts=4 sw=4 et si

roundup/backends/rdbms_common.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.140 2004-11-10 22:22:58 richard Exp $
1+
# $Id: rdbms_common.py,v 1.141 2004-11-25 23:53:31 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2606,10 +2606,10 @@ def set(self, itemid, **propvalues):
26062606
if content:
26072607
# store and index
26082608
self.db.storefile(self.classname, itemid, None, content)
2609+
mime_type = None
26092610
if self.getprops().has_key('type'):
2610-
mime_type = propvalues.get('type', self.get(itemid, 'type',
2611-
self.default_mime_type))
2612-
else:
2611+
mime_type = propvalues.get('type', self.get(itemid, 'type'))
2612+
if not mime_type:
26132613
mime_type = self.default_mime_type
26142614
self.db.indexer.add_text((self.classname, itemid, 'content'),
26152615
content, mime_type)
@@ -2626,9 +2626,10 @@ def index(self, nodeid):
26262626
Pass on the content-type property for the content property.
26272627
'''
26282628
Class.index(self, nodeid)
2629-
try:
2630-
mime_type = self.get(nodeid, 'type', self.default_mime_type)
2631-
except KeyError:
2629+
mime_type = None
2630+
if self.getprops().has_key('type'):
2631+
mime_type = self.get(nodeid, 'type')
2632+
if not mime_type:
26322633
mime_type = self.default_mime_type
26332634
self.db.indexer.add_text((self.classname, nodeid, 'content'),
26342635
str(self.get(nodeid, 'content')), mime_type)

0 commit comments

Comments
 (0)