Thanks.

I'll try those.

Is there any general guidance on when an "argument" that is set with
an assignment statement can be a list?  ('always' would be an
interesting answer...)

On Feb 10, 11:24 am, Lewis <lewis_le...@hotmail.com> wrote:
> The model follows. Focus on the category.name field (and point out
> anything else that looks wrong/inept). Looks like I have belt,
> suspenders, and back-up suspenders for that field.  I need
> category.name to be unique and not empty.  Is it the
> requires=IS_NOT_EMPTY() that forces me to use IS_NOT_IN_DB instead of
> unique=True?
>
> Which is preferred so that postgresql enforces the constraints?
>
> Thanks,Lewis
>
> jodb.define_table('joke',
>     Field('joketext', 'text',length=2048, requires = IS_NOT_EMPTY()),
>     Field('created_on', 'datetime', default=request.now),
>     Field('created_by', jodb.auth_user))
>
> jodb.define_table('category',
>     Field('name', 'string', length=100, unique = True, requires =
> IS_NOT_EMPTY()),
>     Field('created_by', jodb.auth_user) )
>
> jodb.define_table('joke_category',
>     Field('joke', jodb.joke),
>     Field('category', jodb.category),
>     format = '%(name)s')
>
> jodb.joke_category.category.requires = IS_IN_DB(jodb,jodb.category.id,
> multiple=True)
> jodb.category.name.requires = IS_NOT_IN_DB(jodb,jodb.category.name)
> jodb.auth_user._format = '%(first_name)s %(last_name)s'
>
> On Feb 9, 2:06 pm, Anthony <abasta...@gmail.com> wrote:
>
>
>
>
>
>
>
> > On Thursday, February 9, 2012 1:28:28 PM UTC-5,Lewiswrote:
>
> > > Then why did web2py fail with a run time error?  Or why wasn't the run
> > > time error trapped?  Maybe because I had requires on the same table
> > > for a different constraint?
>
> > I assume there must be an explicit "requires" attribute set for that field
> > somewhere, so the automatic setting of "requires" isn't happening. You'll
> > have to show more code.
>
> > > It doesn't look good when visitors to your site see the web2py error
> > > ticket page.
>
> > You can generate friendly error pages -- 
> > seehttp://web2py.com/books/default/chapter/29/4#Routes-on-error. The error
> > page can be a static file, or a dynamically generated page. In the latter
> > case, it might be safer to have the error handler in a separate error
> > handling application -- that way if the error happens to be in a model file
> > of your main app, it won't prevent the error handler from being reached.
>
> > Anthony

Reply via email to