[web2py] Re: multiple 'requires'

2012-02-23 Thread Niphlod
requires can be a list, so you can :

db.ips.ipaddress.requires = [IS_NOT_IN_DB(db, 'ips.ipaddress')]
db.ips.ipaddress.requires.append(IS_IPV4())


Re: [web2py] Re: multiple 'requires'

2012-02-23 Thread Larry G. Wapnitsky

you are a god amongst men!  thank you!

On 2/23/2012 12:19 PM, Niphlod wrote:

db.ips.ipaddress.requires = [IS_NOT_IN_DB(db, 'ips.ipaddress')]
db.ips.ipaddress.requires.append(IS_IPV4())


[web2py] Re: multiple 'requires'

2012-02-23 Thread Anthony
On Thursday, February 23, 2012 12:11:48 PM UTC-5, Larry Wapnitsky wrote:

 I'm trying to use the following in my applications, but only one works at 
 a time:

 db.ips.ipaddress.requires = IS_NOT_IN_DB(db, 'ips.ipaddress')
 db.ips.ipaddress.requires = IS_IPV4()

 How can I get them both to process?


Your second assignment is overwriting your first. For multiple validators, 
put them in a list:

db.ips.ipaddress.requires = [IS_IPV4(), IS_NOT_IN_DB(db, 'ips.ipaddress')]

See http://web2py.com/books/default/chapter/29/7#Validators.

Anthony



[web2py] Re: multiple 'requires'

2012-02-23 Thread Massimo Di Pierro
Notice is works even without the []:

db.ips.ipaddress.requires = IS_IPV4(),
IS_NOT_IN_DB(db,
'ips.ipaddress')

tuples in python do not requires brackets, only commas.

On Feb 23, 11:20 am, Anthony abasta...@gmail.com wrote:
 On Thursday, February 23, 2012 12:11:48 PM UTC-5, Larry Wapnitsky wrote:

  I'm trying to use the following in my applications, but only one works at
  a time:

  db.ips.ipaddress.requires = IS_NOT_IN_DB(db, 'ips.ipaddress')
  db.ips.ipaddress.requires = IS_IPV4()

  How can I get them both to process?

 Your second assignment is overwriting your first. For multiple validators,
 put them in a list:

 db.ips.ipaddress.requires = [IS_IPV4(), IS_NOT_IN_DB(db, 'ips.ipaddress')]

 Seehttp://web2py.com/books/default/chapter/29/7#Validators.

 Anthony


[web2py] Re: multiple 'requires'

2012-02-23 Thread Anthony


 Notice is works even without the []: 

 db.ips.ipaddress.requires = IS_IPV4(), 
 IS_NOT_IN_DB(db, 
 'ips.ipaddress') 

 tuples in python do not requires brackets, only commas.


Though note that tuples are not mutable, so no appending, inserting, etc. 
in that case. 


[web2py] Re: multiple 'requires'

2012-02-23 Thread lyn2py
Learnt something new today. Thanks Massimo :)

On Feb 24, 4:44 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Notice is works even without the []:

 db.ips.ipaddress.requires = IS_IPV4(),
                                         IS_NOT_IN_DB(db,
 'ips.ipaddress')

 tuples in python do not requires brackets, only commas.

 On Feb 23, 11:20 am, Anthony abasta...@gmail.com wrote:







  On Thursday, February 23, 2012 12:11:48 PM UTC-5, Larry Wapnitsky wrote:

   I'm trying to use the following in my applications, but only one works at
   a time:

   db.ips.ipaddress.requires = IS_NOT_IN_DB(db, 'ips.ipaddress')
   db.ips.ipaddress.requires = IS_IPV4()

   How can I get them both to process?

  Your second assignment is overwriting your first. For multiple validators,
  put them in a list:

  db.ips.ipaddress.requires = [IS_IPV4(), IS_NOT_IN_DB(db, 'ips.ipaddress')]

  Seehttp://web2py.com/books/default/chapter/29/7#Validators.

  Anthony