April 16, 2005
4:22 p.m.
Stephan Cieszynski wrote:
class Username(annotate.Typed): def coerce (self, val, configurable): ... d = dbpool.runQuery("""SELECT username FROM userdb WHERE username = %s""", str(val)) d.addCallback(_cb, val) d.addErrback(_eb)
return d
coerce cannot defer. To do that, move your validation into e.g. the start of an autocallable and do something like def foo(self, ctx, foo, bar): if not valid(foo): raise annotate.ValidateError( {'foo': 'Foo is bad.' }, partialForm=ctx.locate(inevow.IRequest).args) ... foo = annotate.autocallable(foo) where the dict is variablename->errormessage. See ValidateError for more.