I defined the following table: db.define_table('applicationform', Field('inschrijving',length='36',default='',notnull=True,ondelete='RESTRICT'), Field('bedrijfsnaam',length=54,default='',notnull=True), Field('kvk_nummer',length=8), Field('subdossiernummer',length=4,default='0000'), Field('rechtsvorm',default='',notnull=True), Field('straat',length=42,default='',notnull=True), Field('huisnummer',length=9,default='',notnull=True), Field('huisnummerextensie',length=6), Field('postcode',length=7,default='',notnull=True), Field('plaats',length=42,default='',notnull=True), Field('telefoonnummer',length=72), Field('faxnummer',length=72), Field('mobielnummer',length=72), Field('email',length=72), Field('website',length=72), Field('aanhef'), Field('first_name',length=24), Field('last_name',length=42,default='',notnull=True), Field('email_persoon',length=72,default='',notnull=True), Field('application',length=24,writable=False,readable=False), Field('created_on',type='datetime',writable=False,readable=False), Field('modified_on',type='datetime',writable=False,readable=False), Field('replied_on',type='datetime',writable=False,readable=False), migrate=False)
db.applicationform.inschrijving.requires=IS_IN_DB(db,db.inschrijving.inschrijving,'% (inschrijving)s',zero=None) db.applicationform.bedrijfsnaam.requires=[IS_LENGTH(54,error_message='lengte overschreidt 54 tekens'),IS_NOT_EMPTY()] db.applicationform.bedrijfsnaam.label='Bedrijfsnaam * ' db.applicationform.kvk_nummer.requires=[IS_MATCH('\d{8}',error_message='geen match 8 cijfers'),IS_NOT_EMPTY()] db.applicationform.kvk_nummer.label='Kvk-nummer * ' db.applicationform.subdossiernummer.requires=[IS_MATCH('\d{4}',error_message='geen match 4 cijfers'),IS_NOT_EMPTY()] db.applicationform.subdossiernummer.default='0000' db.applicationform.subdossiernummer.label='Subdossiernummer * ' db.applicationform.rechtsvorm.requires=IS_IN_DB(db,db.rechtsvorm.rechtsvorm,'% (rechtsvorm)s',zero=None) db.applicationform.rechtsvorm.default='Onbekend' db.applicationform.straat.requires=[IS_LENGTH(42,error_message='lengte overschreidt 42 tekens'),IS_NOT_EMPTY()] db.applicationform.straat.label='Straat * ' db.applicationform.huisnummer.requires=[IS_LENGTH(9,error_message='lengte overschreidt 9 tekens'),IS_NOT_EMPTY()] db.applicationform.huisnummer.label='Huisnummer * ' db.applicationform.huisnummerextensie.requires=IS_LENGTH(6,error_message='length overschreidt 6 tekens') db.applicationform.postcode.requires=[IS_LENGTH(7,error_message='length overschreidt 7 tekens'),IS_NOT_EMPTY()] db.applicationform.plaats.requires=[IS_IN_DB(db,db.plaats.plaats,'% (plaats)s')] db.applicationform.plaats.widget=SQLFORM.widgets.autocomplete(request,db.plaats.plaats,min_length=2) db.applicationform.plaats.label='Plaats * ' db.applicationform.telefoonnummer.requires=IS_LENGTH(72,error_message='lengte overschreidt 72 tekens') db.applicationform.faxnummer.requires=IS_LENGTH(72,error_message='lengte overschreidt 72 tekens') db.applicationform.mobielnummer.requires=IS_LENGTH(72,error_message='lengte overschreidt 72 tekens') db.applicationform.email.requires=[IS_LENGTH(72,error_message='lengte overschreidt 72 tekens'), IS_NULL_OR(IS_EMAIL())] db.applicationform.email.label='E-mail' db.applicationform.website.requires=IS_LENGTH(72,error_message='lengte overschreidt 72 tekens') db.applicationform.website.label='Web site' db.applicationform.aanhef.requires=IS_IN_SET(['de heer','mevrouw'],zero=None) db.applicationform.first_name.requires=IS_LENGTH(24,error_message='lengte overschreidt 24 tekens') db.applicationform.first_name.label='Voornaam' db.applicationform.last_name.requires=[IS_LENGTH(42,error_message='lengte overschreidt 42 tekens'),IS_NOT_EMPTY()] db.applicationform.last_name.label='Achternaam * ' db.applicationform.email_persoon.requires=[IS_LENGTH(72,error_message='lengte overschreidt 72 tekens'), IS_EMAIL(), IS_NOT_EMPTY()] db.applicationform.email_persoon.label='E-mail * ' db.applicationform.application.requires=IS_LENGTH(24,error_message='lengte overschreidt 24 tekens') db.applicationform.created_on.default=request.now db.applicationform.modified_on.default=request.now db.applicationform.modified_on.update=request.now db.applicationform.replied_on.default='' In this function I expose the form: def application_form(): if not len(request.args): redirect(URL(r=request,c='default',f='error')) else: response.functionname='Aanmeldingsformulier' db.applicationform.application.default=request.args(0) form=SQLFORM(db.applicationform) form[0].insert(0,TR(H4('Bedrijfsgegevens:'))) form[0].insert(5,TR(H4('Adresgegevens:'))) form[0].insert(11,TR(H4('Communicatiegegevens:'))) form[0].insert(17,TR(H4('Contactpersoon:'))) form[0][-1][1].append(INPUT(_type='reset',_value='Reset')) if form.accepts(request.vars,session): response.flash='Het formulier is verzonden, u ontvangt binnen 5 werkdagen een reactie' mail.send(to=['ad...@fitwise.nl'], subject='Aanmeldingsformulier ' + form.vars.bedrijfsnaam, message='') form=[] elif form.errors: response.flash=response.flash_formerror else: if request.args(0)=='crm': response.flash='Uw bedrijfsgegevens in ons systeem zijn onvolledig, om die reden is het systeem niet in staat een wijzigingsformulier te genereren. Wij verzoeken u vriendelijk het aanmeldingformulier in te vullen, zodat wij uw bedrijfsgegevens in ons systeem kunnen invoeren.' else: response.flash=response.flash_form return dict(form=form) When the user submits the form I get the following errror: Error traceback Traceback (most recent call last): File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/ restricted.py", line 188, in restricted exec ccode in environment File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/ util/controllers/form.py", line 82, in <module> File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/ globals.py", line 96, in <lambda> self._caller = lambda f: f() File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/ util/controllers/form.py", line 47, in application_form if form.accepts(request.vars,session): File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/ sqlhtml.py", line 1103, in accepts self.vars.id = self.table.insert(**fields) File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/sql.py", line 2029, in insert query = self._insert(**fields) File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/sql.py", line 2009, in _insert value = value[:field.length] TypeError: slice indices must be integers or None or have an __index__ method Error snapshot Detailed traceback description Exception: <type 'exceptions.TypeError'>(slice indices must be integers or None or have an __index__ method) Python 2.5.1: /System/Library/Frameworks/Python.framework/Versions/2.5/ Resources/Python.app/Contents/MacOS/Python File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/ restricted.py in restricted at line 188 [ code | arguments | variables ] File /Library/Python/2.5/site-packages/web2py_1.87.3/applications/util/ controllers/form.py in <module> at line 82 [ code | arguments | variables ] File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/globals.py in <lambda> at line 96 [ code | arguments | variables ] File /Library/Python/2.5/site-packages/web2py_1.87.3/applications/util/ controllers/form.py in application_form at line 47 [ code | arguments | variables ] File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/sqlhtml.py in accepts at line 1103 [ code | arguments | variables ] File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/sql.py in insert at line 2029 [ code | arguments | variables ] File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/sql.py in _insert at line 2009 [ code | arguments | variables ] Function argument list: (self=<Table {'last_name': <gluon.sql.Field object at ...>, '_id': <gluon.sql.Field object at 0x602d570>}>, **fields={'aanhef': 'de heer', 'bedrijfsnaam': 'test', 'email': None, 'email_persoon': 'jmverm...@xs4all.nl', 'faxnummer': '', 'first_name': '', 'huisnummer': '6', 'huisnummerextensie': '', 'inschrijving': 'Fitnesscentrum', 'kvk_nummer': '12345678', ...}) fs.append(fieldname) value = fields[fieldname] if hasattr(value,'id'): value = value.id elif ft == 'string' and isinstance(value, (str,unicode)): value = value[:field.length] vs.append(sql_represent(value, ft, fd, self._db._db_codec)) elif field.default != None: fs.append(fieldname) vs.append(sql_represent(field.default, ft, fd, self._db._db_codec)) field: <gluon.sql.Field object at 0x6015ef0> field.length: '36' value: 'Fitnesscentrum' I defined similar tables and functions which all work, I have no idea why this function returns an error, I hope one of you does. Kind regards, Annet.