[web2py] Re: avoiding duplicate field names

2016-09-16 Thread Alex Glaros
thanks Niphlod, you're right.  Answer is right in the book.  Works now.

my_current_role_names = db(db.Role.role_owner_organization_FK == 
specificOrganizationID)
db.Role.role_name.requires = IS_NOT_IN_DB(my_current_role_names, 
'Role.role_name')

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: avoiding duplicate field names

2016-09-16 Thread Niphlod
the query is right, but *requires=* *require *- excuse the repetition - a 
validator, not a query (those nifty IS_LENGTH() thingies)



On Friday, September 16, 2016 at 5:18:30 AM UTC+2, Alex Glaros wrote:
>
> are there any simple mistakes in this syntax or am I approaching it wrong?
>
> my_current_role_names = db(db.Role.role_owner_organization_FK == 
> specificOrganizationID)._select(db.Role.role_name) 
> db.Role.role_name.requires = ~db.Role.role_name.belongs(
> my_current_role_names)
>
>
> thanks
>
> Alex Glaros
>
>  Validation error, field:role_name (NOT 
> (Role.role_name IN (SELECT Role.role_name FROM Role WHERE 
> (Role.role_owner_organization_FK = 7 'exceptions.Exception'>(Validation error, field:role_name (NOT 
> (Role.role_name IN (SELECT Role.role_name FROM Role WHERE 
> (Role.role_owner_organization_FK = 7)
>
> Code listing
>
> 1862.
> 1863.
> 1864.
> 1865.
> 1866.
> 1867.
>
> 1868.
> 1869.
> 1870.
> 1871.
>
> (value, errors) = validator(value)
> except:
> import traceback
> print traceback.format_exc()
> msg = "Validation error, field:%s %s" % (name,validator)
> raise Exception(msg)
>
> if errors is not None:
> self.vars[name] = value
> self.errors[name] = errors
> break
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.