[web2py] list:integer restrict

2011-11-15 Thread thodoris
Hello,

i would like to do the following but i am not sure how to do it.

I want to define a field like

rank = (0,1,2,3,4,5)

Field('rank','list:integer',requires=IS_IN_SET(rank)),

but i would like to implement the restriction that if for example 1 is
already set, it won't appear in the list.

Any ideas???


Re: [web2py] list:integer restrict

2011-11-15 Thread Manuele

On 15/11/2011 12:28, thodoris wrote:

Hello,

i would like to do the following but i am not sure how to do it.

I want to define a field like

rank = (0,1,2,3,4,5)

Field('rank','list:integer',requires=IS_IN_SET(rank)),

but i would like to implement the restriction that if for example 1 is
already set, it won't appear in the list.

Any ideas???


maybe this can solve?

rank = [1,2,3,4,5]

for i in db(db.tab).select(db.tab.rank):
for j in i:
try:
rank.remove(j)
except:
pass

Field('rank','list:integer',requires=IS_LIST_OF(IS_IN_SET(rank)))

Manuele