my bad, sorry Christian.
myset = { 0:'Quiet',1:'Running',2:'Fail'}
....
Field('action', 'integer',
requires=IS_IN_SET(myset),
represent=lambda value, row: myset.get(value, None)
# or myset[value] if you are totally sure that myset contains all
the possible values
)
Tested !
On Friday, December 21, 2012 12:13:11 AM UTC+1, villas wrote:
>
> I guess you need to use: actions.represent as well.
>
>
> On Thursday, December 20, 2012 9:46:58 PM UTC, Niphlod wrote:
>>
>> Disclaimer: not tested
>> why don't you just change the action Field to
>>
>> Field('action', requires=IS_IN_SET({ 0:'Quiet',1:'Running',2:'Fail'}))
>>
>> On Thursday, December 20, 2012 10:23:07 PM UTC+1, Jim S wrote:
>>>
>>> Have you though about adding a table to define the relation between
>>> 'index' and the text:
>>>
>>> db_actions.define_table('actions',
>>> Field(name, length=20, label='Action'))
>>>
>>> Then modify db_events so field index looks like:
>>>
>>> Field('index', db.actions, label='Action),
>>>
>>> Table actions would then have three records,
>>>
>>> Quiet
>>> Running
>>> Fail
>>>
>>> This should then automatically display the right value - the only
>>> problem is that it wouldn't guarantee that the index would be 0, 1, and 2.
>>> It would be whatever the primary key on the actions table worked out to be.
>>>
>>> The other way to handle it would be to write a custom validator that
>>> changed the numeric value as you mentioned. I haven't done that before,
>>> but heard it isn't that difficult.
>>>
>>> -Jim
>>>
>>> On Thu, Dec 20, 2012 at 2:45 PM, Christian Espinoza
>>> <[email protected]>wrote:
>>>
>>>> My Model for this App
>>>> db_events.define_table('events',
>>>> Field('devid', length=15, label='CODE'),
>>>> Field('type', length=15, label='Type'),
>>>> Field('index','integer', label='Action'),
>>>> Field('datetime','datetime', label='Date'),
>>>> Field('latitude','double', label='Lat'),
>>>> Field('longitude','double', label='Lon'),
>>>> Field('velocity','double', label='Vel'),
>>>> Field('heading', 'integer', label='Dir'),
>>>> Field('pfm','integer', label='PFM'),
>>>> Field('age','integer', label='Age'),
>>>> Field('odometer','double', label='Od')
>>>> )
>>>> --
>>>>
>>>>
>>>>
>>>>
>>>
>>>
--