
Hello *. I want to validate forminput against a database. For this reason, i wrote my own class: class Username(annotate.Typed): def coerce (self, val, configurable): [some code] def _eb(r): raise annotate.InputError('database error') # this works very well: # def _cb(r, val): # if len(r): # return r[0][0] # return '' # if the username already in use, i want to raise an exception: # the errormessage isn't placed correct in the rendered # 'form'page, but the whole exceptionpage is filled in # in the slot('error') of this input field def _cb(r, val): if len(r): raise annotate.InputError("username in use") return val d = dbpool.runQuery("""SELECT username FROM userdb WHERE username = %s""", str(val)) d.addCallback(_cb, val) d.addErrback(_eb) return d dbpool.runQuery returns a deferred. If i want to use the username returned by the query, the result is placed correctly in the formfield. But if an exception raised (here: InputError), the delay by the deferred is to long and the whole exceptionpage is placed in the slot('error'), not the message ('username in use') only. Is my way right? Is there a way to solve this problem? Stephan