On Wed, Apr 22, 2009 at 11:19 AM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> You can make the field integer and then do
>
> db.mytable.myfield.requires=IS_IN_SET(range(3),('dog','cat','mouse'))
>
> This would be a enum.

Ok, but with this I can't add this way:
db.mytable.insert(myfield='cat')

So, what I have to do?

I think:

myvalues = {'dog': 0, 'cat': 1, 'mouse': 2}
mylist = map(lambda x:x, myvalues)
db.mytable.myfield.requires = IS_IN_SET(range(mylist), mylist)

and

db.mytable.insert(myfield=myvalues['cat'])

But if this field is "ENUM", I think web2py have to handle this, not I
(with dicts and lists above).

-- 
 Álvaro Justen
 Peta5 - Telecomunicações e Software Livre
 21 3021-6001 / 9898-0141
 http://www.peta5.com.br/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to