I am trying to write my own validators following the examples that comes
with FormKit, but they always raise an exception - and I can't figure
out why (the example works). I also get the same exception at some of my
pages when using the validators that come with FormKit.
Here's the traceback:
Traceback (most recent call last):
File "WebKit/Application.py", line 415, in dispatchRequest
self.handleGoodURL(transaction)
File "WebKit/Application.py", line 567, in handleGoodURL
self.respond(transaction)
File "WebKit/Application.py", line 776, in respond
transaction.respond()
File "WebKit/Transaction.py", line 105, in respond
self._servlet.respond(self)
File "/home/kiowa/cvs/nsadmin/SitePage.py", line 137, in respond
Page.respond(self,trans)
File "WebKit/HTTPServlet.py", line 38, in respond
method(trans)
File "WebKit/Page.py", line 38, in respondToPost
self._respond(transaction)
File "WebKit/Page.py", line 70, in _respond
self.handleAction(action)
File "WebKit/Page.py", line 264, in handleAction
self.preAction(action)
File "FormKit/FormKitMixIn.py", line 69, in preAction
form.process( fields )
File "FormKit/Form.py", line 141, in process
field._processRawValues( inputData )
File "FormKit/BaseFieldClasses.py", line 70, in _processRawValues
self._value =3D validator._attemptConvert(value) # get the validated va=
lue, if possible
AttributeError: CompanyDoesNotExist instance has no attribute '_attemptConv=
ert'
Here's the code for the validator I wrote:
class CompanyDoesNotExist(BaseValidatorClasses.FormValidator,SitePage):
""" Make sure a company doesn't exist before we add it """
def validate(self,valueDict):
if self.compExists(valueDict['name']):
raise BaseValidatorClasses.InvalidField, "This company
already exists."
def validatePartialForm(self):
return 1
--=20
Alexander Brill <kiowa@...>
http://www.project23.no
PGP-key: http://alexb.egil.org/key.pub
|