ok. This may be a bug. I will look into it.

On Aug 29, 1:27 pm, Adrian Klaver <[email protected]> wrote:
> On Saturday 28 August 2010 10:04:28 pm mdipierro wrote:
>
> > You cannot use default=Expression('CURRENT_DATE',db=db) I.e. have the
> > default date inserted by the database and, at the same time, validate
> > the field at the web2py level (before) the record is communicated by
> > the database.  The field has to be writable=readable=False if you want
> > to use it in forms.
>
> I tried that :)
>
> db.define_table('default_test',
> Field('date_default','date',default=Expression('CURRENT_DATE',db=db),writable=False,readable=False,notnull=True),
> Field('txt_fld','text'))
>
> And got:
>
> Traceback (most recent call last):
>   File "/home/aklaver/software_projects/w2py/web2py/gluon/restricted.py", line
> 188, in restricted
>     exec ccode in environment
>
> File 
> "/home/aklaver/software_projects/w2py/web2py/applications/hplc/controllers/default.py",
> line 65, in <module>
>   File "/home/aklaver/software_projects/w2py/web2py/gluon/globals.py", line 
> 96,
> in <lambda>
>     self._caller = lambda f: f()
>
> File 
> "/home/aklaver/software_projects/w2py/web2py/applications/hplc/controllers/default.py",
> line 57, in default_test
>     if form.accepts(request.vars, session):
>   File "/home/aklaver/software_projects/w2py/web2py/gluon/sqlhtml.py", line
> 1055, in accepts
>     self.vars.id = self.table.insert(**fields)
>   File "/home/aklaver/software_projects/w2py/web2py/gluon/sql.py", line 2013, 
> in
> insert
>     query = self._insert(**fields)
>   File "/home/aklaver/software_projects/w2py/web2py/gluon/sql.py", line 2004, 
> in
> _insert
>     sql_v = ', '.join(vs)
> TypeError: sequence item 0: expected string, Expression found
>
> Thanks,
>
> --
> Adrian Klaver
> [email protected]

Reply via email to