From c74b57333c6b5aab070d35d2964eded8b20d37ec Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 18 Feb 2003 01:57:39 +0000 Subject: [PATCH] don't attempt to create FileClass items if no content is supplied git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1520 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/back_anydbm.py | 4 ++-- roundup/backends/back_metakit.py | 2 +- roundup/backends/rdbms_common.py | 4 ++-- roundup/cgi/client.py | 15 ++++++++++++++- roundup/hyperdb.py | 8 +++++++- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 1971cca..ab7c06a 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -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.103 2003-02-14 00:31:44 richard Exp $ +#$Id: back_anydbm.py,v 1.104 2003-02-18 01:57:38 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 @@ -1879,7 +1879,7 @@ class Class(hyperdb.Class): for react in self.reactors[action]: react(self.db, self, nodeid, oldvalues) -class FileClass(Class): +class FileClass(Class, hyperdb.FileClass): '''This class defines a large chunk of data. To support this, it has a mandatory String property "content" which is typically saved off externally to the hyperdb. diff --git a/roundup/backends/back_metakit.py b/roundup/backends/back_metakit.py index 9e5a8b8..91a5934 100755 --- a/roundup/backends/back_metakit.py +++ b/roundup/backends/back_metakit.py @@ -1199,7 +1199,7 @@ _typmap = { hyperdb.Boolean : 'I', hyperdb.Number : 'I', } -class FileClass(Class): +class FileClass(Class, hyperdb.FileClass): ''' like Class but with a content property ''' default_mime_type = 'text/plain' diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index 1fa6cd8..e663a19 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -1,4 +1,4 @@ -# $Id: rdbms_common.py,v 1.33 2003-02-14 00:31:45 richard Exp $ +# $Id: rdbms_common.py,v 1.34 2003-02-18 01:57:39 richard Exp $ ''' Relational database (SQL) backend common code. Basics: @@ -1977,7 +1977,7 @@ class Class(hyperdb.Class): for react in self.reactors[action]: react(self.db, self, nodeid, oldvalues) -class FileClass(Class): +class FileClass(Class, hyperdb.FileClass): '''This class defines a large chunk of data. To support this, it has a mandatory String property "content" which is typically saved off externally to the hyperdb. diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 3559e75..b4c91b8 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.89 2003-02-17 06:44:00 richard Exp $ +# $Id: client.py,v 1.90 2003-02-18 01:57:39 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -1169,6 +1169,10 @@ class Client: :file - create a file, attach to the current item and any message created by :note. This is ALWAYS designated "file-1". + + We also check that FileClass items have a "content" property with + actual content, otherwise we remove them from all_props before + returning. ''' # some very useful variables db = self.db @@ -1512,6 +1516,15 @@ class Client: if s: raise ValueError, '\n'.join(s) + # check that FileClass entries have a "content" property with + # content, otherwise remove them + for (cn, id), props in all_props.items(): + cl = self.db.classes[cn] + if not isinstance(cl, hyperdb.FileClass): + continue + if not props.get('content', ''): + del all_props((cn, id)) + return all_props, all_links def fixNewlines(text): diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 56f7ab0..52c9acc 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.84 2002-10-07 00:52:51 richard Exp $ +# $Id: hyperdb.py,v 1.85 2003-02-18 01:57:38 richard Exp $ """ Hyperdatabase implementation, especially field types. @@ -561,6 +561,12 @@ class Class: ''' raise NotImplementedError +class FileClass: + ''' A class that requires the "content" property and stores it on + disk. + ''' + pass + class Node: ''' A convenience wrapper for the given node ''' -- 2.39.5