Il 14/07/14 02:27, Don O'Hara ha scritto:
> I'm experimenting with the various field types (mysql) to learn more
> about web2py.
> I'm not sure why I got this error
>
> <type 'exceptions.AttributeError'> 'str' object has no attribute
> 'writable'
>
> Version
> web2py^(TM)Version 2.9.5-trunk+timestamp.2014.07.03.12.21.52
>
>
> Given this table:
>
> db.define_table('test_all_fields',
> Field('f1_boolean','boolean'),
> Field('f1a_string'),
> Field('f2_text','text'),
> Field('f3_json','json'),
> Field('f4_password','password'),
> Field('f5_blob','blob'),
> Field('f6_upload','upload'),
> Field('f7_integer','integer'),
> Field('f8_bigint','bigint'),
> Field('f10_double','double'),
> Field('f11_decimal','decimal(8,2)'),
> Field('f12_date','date'),
> Field('f13_time','time'),
> Field('f14_datetime','datetime'),
> #Field('f15_list_integer','list:integer'),
> #Field('f16_list_string','list:string'),
> )
>
> I wanted to display a record from it using SQLFORM, with all defaults:
>
> row=db.test_all_fields(request.args[1])
> form=SQLFORM(row)
you forgot to pass the table to the SQLFORM init... have you seen the
full SQLFORM signature?
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM
cheers
M.
>
>
> The error is being thrown in gluon/sqlhtml.py, line 1037:
>
> Aren't the default attributes for a Field maintained throughout?
>
> Thanks!!
>
> Don
>
> |Field(name, 'string', length=None, default=None,
> required=False, requires='<default>',
> ondelete='CASCADE', notnull=False, unique=False,
> uploadfield=True, widget=None, label=None, comment=None,
> writable=True, readable=True, update=None, authorize=None,
> autodelete=False, represent=None, compute=None,
> uploadfolder=None,
> uploadseparate=None,uploadfs=None)|
>
>
>
>
>
> Code listing
>
> 1032.
> 1033.
> 1034.
> 1035.
> 1036.
> 1037.
>
> 1038.
> 1039.
> 1040.
> 1041.
>
> # if no fields are provided, build it from the provided table
> # will only use writable or readable fields, unless forced to ignore
> if fields is None:
> fields = [f.name for f in table if
> (ignore_rw or f.writable or f.readable) and
>
> (readonly or not f.compute)]
> self.fields = fields
>
> # make sure we have an id
>
>
> Variables
>
> ignore_rw False
> f.readable undefined
> f.writable undefined
> f 'f4_password'
>
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.