On Dec 23, 2010, at 6:42 AM, DenesL wrote:
> 
> 
> Two things to check:
> 1) you might have session.forget() in the controller, maybe outside
> the action.
> 2) you might be using a custom form and it is missing the hidden
> fields,
>   if you don't have the _formkey then the form will not be accepted.

Also, if the submit results in a database insert, and the insert fails. I think.

And if there's a formname mismatch.

It seems to me that if accepts() fails, there always ought to be a reason 
reported. Would it break compatibility to report these errors in form.errors? 
If so, how about creating form.formerrors and guaranteeing that if accepts 
returns False, formerrors will say why.

> The Form docstring says:
> 
>     form has one important method::
> 
>         form.accepts(request.vars, session)
> 
>     if form is accepted (and all validators pass) form.vars contains the
>     accepted vars, otherwise form.errors contains the errors.
>     in case of errors the form is modified to present the errors to the user.
> 
...but that's not really true. There are several reasons for failure that are 
not reported in form.errors.

(One of them is that the form has not been submitted yet. I find that logic 
really confusing: what's the path, exactly?)

> 
> 
> On Dec 23, 2:39 am, Johann Spies <johann.sp...@gmail.com> wrote:
>> On 22 December 2010 22:36, Jonathan Lundell <jlund...@pobox.com> wrote:
>> 
>> 
>> 
>>> When accepts() returns False, look at form.errors. It's a dict (Storage,
>>> actually, but you can treat it as a dict) that is keyed, typically, by field
>>> names, with error messages as values.
>> 
>>> (accepts() will also return False before the form has been submitted, but
>>> in that case form.errors is empty.)
>> 
>> Thanks.  I have tried that before also but it just reports Storage{}
>> 
>> So why is that empty?
>> 
>> Regards
>> Johann
>> 
>> --
>>  May grace and peace be yours in abundance through the full knowledge of God
>> and of Jesus our Lord!  His divine power has given us everything we need for
>> life and godliness through the full knowledge of the one who called us by
>> his own glory and excellence.
>>                                                     2 Pet. 1:2b,3a


Reply via email to