Skip to content

Commit 70c6667

Browse files
author
Richard Jones
committed
don't attempt to create FileClass items if no content is supplied
1 parent f2b6741 commit 70c6667

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 2 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.103 2003-02-14 00:31:44 richard Exp $
18+
#$Id: back_anydbm.py,v 1.104 2003-02-18 01:57:38 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -1879,7 +1879,7 @@ def fireReactors(self, action, nodeid, oldvalues):
18791879
for react in self.reactors[action]:
18801880
react(self.db, self, nodeid, oldvalues)
18811881

1882-
class FileClass(Class):
1882+
class FileClass(Class, hyperdb.FileClass):
18831883
'''This class defines a large chunk of data. To support this, it has a
18841884
mandatory String property "content" which is typically saved off
18851885
externally to the hyperdb.

roundup/backends/back_metakit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ class FileName(hyperdb.String):
11991199
hyperdb.Boolean : 'I',
12001200
hyperdb.Number : 'I',
12011201
}
1202-
class FileClass(Class):
1202+
class FileClass(Class, hyperdb.FileClass):
12031203
''' like Class but with a content property
12041204
'''
12051205
default_mime_type = 'text/plain'

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.33 2003-02-14 00:31:45 richard Exp $
1+
# $Id: rdbms_common.py,v 1.34 2003-02-18 01:57:39 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1977,7 +1977,7 @@ def fireReactors(self, action, nodeid, oldvalues):
19771977
for react in self.reactors[action]:
19781978
react(self.db, self, nodeid, oldvalues)
19791979

1980-
class FileClass(Class):
1980+
class FileClass(Class, hyperdb.FileClass):
19811981
'''This class defines a large chunk of data. To support this, it has a
19821982
mandatory String property "content" which is typically saved off
19831983
externally to the hyperdb.

roundup/cgi/client.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.89 2003-02-17 06:44:00 richard Exp $
1+
# $Id: client.py,v 1.90 2003-02-18 01:57:39 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -1169,6 +1169,10 @@ class <designator> (where <designator> must be
11691169
:file - create a file, attach to the current item and any
11701170
message created by :note. This is ALWAYS designated
11711171
"file-1".
1172+
1173+
We also check that FileClass items have a "content" property with
1174+
actual content, otherwise we remove them from all_props before
1175+
returning.
11721176
'''
11731177
# some very useful variables
11741178
db = self.db
@@ -1512,6 +1516,15 @@ class <designator> (where <designator> must be
15121516
if s:
15131517
raise ValueError, '\n'.join(s)
15141518

1519+
# check that FileClass entries have a "content" property with
1520+
# content, otherwise remove them
1521+
for (cn, id), props in all_props.items():
1522+
cl = self.db.classes[cn]
1523+
if not isinstance(cl, hyperdb.FileClass):
1524+
continue
1525+
if not props.get('content', ''):
1526+
del all_props((cn, id))
1527+
15151528
return all_props, all_links
15161529

15171530
def fixNewlines(text):

roundup/hyperdb.py

Lines changed: 7 additions & 1 deletion
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: hyperdb.py,v 1.84 2002-10-07 00:52:51 richard Exp $
18+
# $Id: hyperdb.py,v 1.85 2003-02-18 01:57:38 richard Exp $
1919

2020
"""
2121
Hyperdatabase implementation, especially field types.
@@ -561,6 +561,12 @@ def index(self, nodeid):
561561
'''
562562
raise NotImplementedError
563563

564+
class FileClass:
565+
''' A class that requires the "content" property and stores it on
566+
disk.
567+
'''
568+
pass
569+
564570
class Node:
565571
''' A convenience wrapper for the given node
566572
'''

0 commit comments

Comments
 (0)