I defined a table eventList:

db.define_table('EventList',
   ...
    Field('description',type='text'),
    Field('shortdescr',length=128,writable=False,readable=False),
    ....
    migrate=False)

db.EventList.description.requires=IS_LENGTH(1536,error_message='length 
exceeds 1536 characters')
db.EventList.shortdescr.requires=IS_LENGTH(128,error_message='length 
exceeds 128 characters')

shortdescr should be the first 128 characters of description followed by 
three dots. In a function this works:

x=len(form.vars.description)
if x>128:
    i=128
    dots="..."
else:
    i=x-1
    dots=""
s=form.vars.description[0:i] + dots

... but I'd like to add it to the model file. I had a look at the compute 
option but wasn't able to figure out how to get it syntactically correct.


Kind regards,

Annet.

Reply via email to