[web2py] Re: list:reference validation

2011-12-18 Thread Nik Go
Anthony, could you elaborate a bit on that notation?
multiple=(0,3)

I wanted a maximum of two items and yet I need to write 3. In the book,
I've seen something similar with the limitby argument for DAL select:
for row in db().select(db.person.ALL, limitby=(0, 2)): print row.name

which fetches the first two, starting at zero records.


On Friday, December 16, 2011, Anthony wrote:

 Shhh! It's a secret.

 Actually, it has been added to the new 4th edition, which should be
 available online soon.

 Anthony

 On Thursday, December 15, 2011 7:06:21 PM UTC-5, ニコノコ wrote:

 Thanks Anthony. I don't think I've seen that in the docs.

 On Thursday, December 15, 2011, Anthony wrote:

 Try

 IS_IN_DB(..., multiple=(0, 3))

 The multiple argument to IS_IN_SET and IS_IN_DB can be a list or tuple
 specifying a minimum and maximum number of items to be selected (strictly
 less than on the max, so set the max to 3 to make sure there are no more
 than 2).

 Anthony

 On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or
 up to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's
 any built-in validator that should work? I've tried the following,
 none of which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')






[web2py] Re: list:reference validation

2011-12-18 Thread Anthony
It does:

min = len(values)  max

Note it's a strict less than for the max, so if you want = 2 values, that 
is equivalent to  3. Basically, it's an inclusive min but an exclusive max.

Anthony

On Sunday, December 18, 2011 7:40:10 PM UTC-5, ニコノコ wrote:

 Anthony, could you elaborate a bit on that notation?
 multiple=(0,3)

 I wanted a maximum of two items and yet I need to write 3. In the book, 
 I've seen something similar with the limitby argument for DAL select:
 for row in db().select(db.person.ALL, limitby=(0, 2)): print row.name

 which fetches the first two, starting at zero records.


 On Friday, December 16, 2011, Anthony wrote:

 Shhh! It's a secret.

 Actually, it has been added to the new 4th edition, which should be 
 available online soon.

 Anthony

 On Thursday, December 15, 2011 7:06:21 PM UTC-5, ニコノコ wrote:

 Thanks Anthony. I don't think I've seen that in the docs.

 On Thursday, December 15, 2011, Anthony wrote:

 Try

 IS_IN_DB(..., multiple=(0, 3))

 The multiple argument to IS_IN_SET and IS_IN_DB can be a list or 
 tuple specifying a minimum and maximum number of items to be selected 
 (strictly less than on the max, so set the max to 3 to make sure there are 
 no more than 2).

 Anthony

 On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or 
 up to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's 
 any built-in validator that should work? I've tried the following, 
 none of which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')



 

[web2py] Re: list:reference validation

2011-12-15 Thread Nik Go
Thanks Anthony. I don't think I've seen that in the docs.

On Thursday, December 15, 2011, Anthony wrote:

 Try

 IS_IN_DB(..., multiple=(0, 3))

 The multiple argument to IS_IN_SET and IS_IN_DB can be a list or tuple
 specifying a minimum and maximum number of items to be selected (strictly
 less than on the max, so set the max to 3 to make sure there are no more
 than 2).

 Anthony

 On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or up
 to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's any
 built-in validator that should work? I've tried the following, none of
 which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')






[web2py] Re: list:reference validation

2011-12-15 Thread Anthony
Shhh! It's a secret.

Actually, it has been added to the new 4th edition, which should be 
available online soon.

Anthony

On Thursday, December 15, 2011 7:06:21 PM UTC-5, ニコノコ wrote:

 Thanks Anthony. I don't think I've seen that in the docs.

 On Thursday, December 15, 2011, Anthony wrote:

 Try

 IS_IN_DB(..., multiple=(0, 3))

 The multiple argument to IS_IN_SET and IS_IN_DB can be a list or tuple 
 specifying a minimum and maximum number of items to be selected (strictly 
 less than on the max, so set the max to 3 to make sure there are no more 
 than 2).

 Anthony

 On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or up 
 to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's 
 any built-in validator that should work? I've tried the following, none 
 of which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')



 

[web2py] Re: list:reference validation

2011-12-15 Thread Joseph Jude
There should be an option in google groups to like a reply which brings a 
bit of smile :-)

[web2py] Re: list:reference validation

2011-12-14 Thread Anthony
Try

IS_IN_DB(..., multiple=(0, 3))

The multiple argument to IS_IN_SET and IS_IN_DB can be a list or tuple 
specifying a minimum and maximum number of items to be selected (strictly 
less than on the max, so set the max to 3 to make sure there are no more 
than 2).

Anthony

On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or up 
 to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's any 
 built-in validator that should work? I've tried the following, none of 
 which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')