From 8bed4a7f4d03d144ddf5edf6b8b8868cbf0e6519 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 5 May 2008 23:32:45 +0000 Subject: [PATCH] Fixed a bug where the Valid_id() validator would raise a TypeError when given a None value. Now raising a ValueError instead. --- NEWS | 2 ++ controller/Database.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 02c3f43..7a43b3e 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ """ character entity so it doesn't show up as a change in the diff. * Fixed a bug where attempting to load a notebook preview without access would give a "list index out of range" error instead of an access error. + * Fixed a bug where the Valid_id() validator would raise a TypeError when + given a None value. Now raising a ValueError instead. 1.3.13: May 5, 2008 * Instructions for enabling JavaScript, linked from various forms that diff --git a/controller/Database.py b/controller/Database.py index 9e45dbc..855e6a6 100644 --- a/controller/Database.py +++ b/controller/Database.py @@ -343,7 +343,12 @@ class Valid_id( object ): self.__none_okay = none_okay def __call__( self, value ): - if self.__none_okay and value in ( None, "None", "" ): return None + if value in ( None, "None", "" ): + if self.__none_okay: + return None + else: + raise ValueError() + if self.ID_PATTERN.search( value ): return str( value ) raise ValueError()