Which web2py version? Which database/adapter??

But I think for unique=True you shouldn't have this error at least if you
had also implement a validator IS_NOT_IN_DB()... unique=True tell the
database to implement unique constrain, but you have to tell the front end
(IS_NOT_IN_DB()) too...

I use to fall on ticket thrown by web2py for unique constrain, but it was
for constrain defined only in the backend/database that applies over more
than one field or involve foreign key field, unique constrain over 2
tables, if I recall... I had to write some logic to catch those error and
return the proper end user error message.

In your case, if you have only a unique constrain over one field, I guess
you can just write the proper validator rule with IS_NOT_IN_DB... To fix
your issue...

Richard

On Thu, Jun 29, 2017 at 9:42 AM, Chris <[email protected]> wrote:

> Hello!
>
> I'm running 2.14.6-stable+timestamp.2016.05.10.00.21.47 and have hit this
> issue:
>
> If I have a Field where unique=True, inserting a row with a duplicate
> Field value triggers the constraint, as expected. However, the error does
> not lead to a page linking to a ticket, but instead to a generic page
> saying Server Error.
>
> I've traced the error down to this section of globals.py:
>
>     @property
>     def body(self):
>         if self._body is None:
>             try:
>                 self._body = copystream_progress(self)
>             except IOError:
>                 raise HTTP(400, "Bad Request - HTTP body is incomplete")
>         return self._body
>
>
> The error thrown by copystream_progress is of type <class
> 'socket.timeout'>, and seems to occur because of a timeout opening
> env['wsgi.input'] (globals.py, copystream_progress)
>
> I haven't been able to trace the error further, but here's the Rocket
> output to stderr:
>
>
> ERROR:Rocket.Errors.Thread-6:Traceback (most recent call last):
>
>   File "\dynamic\gluon\rocket.py", line 1337, in run
>     self.run_app(conn)
>
>   File "\dynamic\gluon\rocket.py", line 1838, in run_app
>     output = self.app(environ, self.start_response)
>
>   File "\dynamic\gluon\main.py", line 653, in app_with_logging
>     ret[0] = wsgiapp(environ, responder2)
>
>   File "\dynamic\gluon\main.py", line 564, in wsgibase
>     return wsgibase(new_environ, responder)
>
>   File "\dynamic\gluon\main.py", line 534, in wsgibase
>     if request.body:
>
>   File "\dynamic\gluon\globals.py", line 281, in body
>     raise HTTP(400, "Bad Request - HTTP body is incomplete")
>
> HTTP: 400 BAD REQUEST
>
> Any help you can give would be most welcome!
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to