comparison roundup/cgi/client.py @ 1731:778056dc420f

Fixed editing properties on FileClass nodes. Previously, if there was no 'content' property in the form when editing properties, other changes wold be discarded silently. Now, an exception is raised when there is a empty content property. Also, when there is no content property, other attributes can be edited.
author Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
date Sun, 10 Aug 2003 13:38:43 +0000
parents 2dd6b4c825e9
children 2c26b6cec950
comparison
equal deleted inserted replaced
1730:2dd6b4c825e9 1731:778056dc420f
1 # $Id: client.py,v 1.127 2003-08-10 10:30:56 jlgijsbers Exp $ 1 # $Id: client.py,v 1.128 2003-08-10 13:38:43 jlgijsbers Exp $
2 2
3 __doc__ = """ 3 __doc__ = """
4 WWW request handler (also used in the stand-alone server). 4 WWW request handler (also used in the stand-alone server).
5 """ 5 """
6 6
1951 s.append('Required %s %s %s not supplied'%(thing[0], p, 1951 s.append('Required %s %s %s not supplied'%(thing[0], p,
1952 ', '.join(required))) 1952 ', '.join(required)))
1953 if s: 1953 if s:
1954 raise ValueError, '\n'.join(s) 1954 raise ValueError, '\n'.join(s)
1955 1955
1956 # check that FileClass entries have a "content" property with 1956 # When creating a FileClass node, it should have a non-empty content
1957 # content, otherwise remove them 1957 # property to be created. When editing a FileClass node, it should
1958 # either have a non-empty content property or no property at all. In
1959 # the latter case, nothing will change.
1958 for (cn, id), props in all_props.items(): 1960 for (cn, id), props in all_props.items():
1959 cl = self.db.classes[cn] 1961 if isinstance(self.db.classes[cn], hyperdb.FileClass):
1960 if not isinstance(cl, hyperdb.FileClass): 1962 if id == '-1':
1961 continue 1963 if not props.get('content', ''):
1962 # we also don't want to create FileClass items with no content 1964 del all_props[(cn, id)]
1963 if not props.get('content', ''): 1965 elif props.has_key('content') and not props['content']:
1964 del all_props[(cn, id)] 1966 raise ValueError, _('File is empty')
1965 return all_props, all_links 1967 return all_props, all_links
1966 1968
1967 def fixNewlines(text): 1969 def fixNewlines(text):
1968 ''' Homogenise line endings. 1970 ''' Homogenise line endings.
1969 1971

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