|
From: Kevin A. <ka...@us...> - 2004-05-10 17:16:23
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17987/tools/resourceEditor/modules Modified Files: propertyEditor.py Log Message: added validation code for name attribute Index: propertyEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/modules/propertyEditor.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** propertyEditor.py 9 May 2004 04:11:57 -0000 1.46 --- propertyEditor.py 10 May 2004 17:16:13 -0000 1.47 *************** *** 10,13 **** --- 10,14 ---- import resourceOutput import time + import string import wx *************** *** 131,135 **** wName, wClass = self.components.wComponentList.stringSelection.split(" : ") propName = self.components.wPropertyList.stringSelection ! # KEA 2002-02-23 ##if propName not in cantmodify: --- 132,136 ---- wName, wClass = self.components.wComponentList.stringSelection.split(" : ") propName = self.components.wPropertyList.stringSelection ! # KEA 2002-02-23 ##if propName not in cantmodify: *************** *** 151,154 **** --- 152,181 ---- pass + # KEA 2004-05-10 + # need to figure out where to stick validation code + # but for now just need to make sure that if we're changing the name + # attribute that it is valid, but similar checks will be necessary for + # integer fields, a list of items, etc. + # also maybe each attribute should have a doc or help string displayed + # saying what the attribute does, example values, etc. + if propName == 'name': + badValue = False + # if it isn't valid then display an alert and exit + # must start with a letter and only contain alphanumeric characters + if value == "" or value[0] not in string.ascii_letters: + badValue = True + else: + alphanumeric = string.ascii_letters + string.digits + for c in value: + if c not in alphanumeric: + badValue = True + break + if badValue: + dialog.alertDialog(None, "Name must start with a letter and only contain letters and numbers.", 'Error: Name is invalid') + self.components.wField.setFocus() + self.components.wField.setSelection(-1, -1) + return + # check for duplicate names is done below + ##widget = self.components[wName] widget = self._comp[wName] |