It is also worth mentioning that this form that now has the error was 
working fine before i deleted the db files. Please advise.

-Brandon

On Monday, May 21, 2012 4:05:20 PM UTC-6, Brandon Reynolds wrote:
>
> I did in fact inspect the database and there was a yearstring field. I 
> think what happened is when i defined the field year i forgot the comma 
> between year and string so 'year' 'string became yearstring. Then when i 
> noticed and fixed the issue it added year field but left yearstring in the 
> db. However i since erased the db(since i am only working on a test right 
> now) and used fake_migrate to replace the tables. I now am getting this 
> error:
>
> <type 'exceptions.TypeError'>('str' object is not callable)
>
> Do you have any advice on this now? It is on another table. Here is the 
> M/V/C:
>
> # coding: utf8 db.define_table('park', Field('park_name', 'string', 
> requires=IS_NOT_EMPTY()), Field('park_city', 'string', 
> requires=IS_NOT_EMPTY()), Field('park_state', 'string', 
> requires=IS_NOT_EMPTY()), Field('park_address', 'string', 
> requires=IS_NOT_EMPTY()), Field('park_zip', 'string', 
> requires=IS_NOT_EMPTY()), Field('country', 'string', default="USA", 
> notnull=True, readable=False, writable=False), Field('park_phone', 
> 'string', requires=IS_MATCH('[\d\-\(\) ]+')), Field('park_fax', 'string', 
> requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))), Field('park_phone_2', 
> 'string', requires=IS_EMPTY_OR(('[\d\-\(\) ]+'))), Field('photo1', 
> 'upload'), Field('photo2', 'upload'), Field('photo3', 'upload'), 
> Field('photo4', 'upload'), Field('photo5', 'upload'), Field('manager', 
> 'string', requires=IS_NOT_EMPTY()), Field('manager_email', 'string', 
> requires=IS_EMAIL()), Field('spaces', 'integer', requires=IS_NOT_EMPTY()), 
> Field('vacant', 'integer'), Field('lot_rent', 'integer', 
> requires=IS_NOT_EMPTY()), Field('water', 'boolean'), Field('sewer', 
> 'boolean'), Field('trash', 'boolean'), Field('pool', 'boolean'), 
> Field('playground', 'boolean'), Field('clubhouse', 'boolean'), 
> Field('laundromat', 'boolean'), Field('rv_spaces', 'boolean'), 
> Field('storage', 'boolean'), Field('handicap_accessible', 'boolean'), 
> Field('community_description', 'text'), format='%(park_name)s') 
> db.define_table('home', Field('pid', notnull=True, readable=False, 
> writable=False), Field('lot', 'string'), Field('year', length=4, 
> requires=IS_NOT_EMPTY()), Field('make', 'string'), Field('model', 
> 'string'), Field('for_sale', 'boolean', default=True), Field('beds', 
> 'string', requires=IS_NOT_EMPTY()), Field('baths', 'string', 
> requires=IS_NOT_EMPTY()), Field('fridge', 'boolean'), Field('stove', 
> 'boolean'), Field('dishwasher', 'boolean'), Field('microwave', 'boolean'), 
> Field('washer', 'boolean'), Field('dryer', 'boolean'), Field('photo1', 
> 'upload'), Field('photo2', 'upload'), Field('photo3', 'upload'), 
> Field('photo4', 'upload'), Field('photo5', 'upload'), Field('price', 
> 'string' , requires=IS_NOT_EMPTY()), Field('description', 'text', 
> requires=IS_NOT_EMPTY())) db.define_table('state', Field('name', 'string'), 
> Field('full_name', 'string')) db.park.park_state.requires = IS_IN_DB(db, '
> state.name', '%(name)s', zero=T('Select State')) 
>
>
> @auth.requires_membership('Admin') def new_park(): form = 
> crud.create(db.park, next='park/[id]') return locals() 
> @auth.requires_membership('Admin') def new_home(): db.home.pid.default = 
> request.args(0) or redirect(URL('parks')) db.home.price.default = 
> "$0000.00" form = crud.create(db.home, next='home/[id]') return locals() 
> @auth.requires_membership('Admin') def edit_park(): park = 
> db.park(request.args(0)) or redirct(URL('parks')) form = 
> crud.update(db.park, park, next='park/[id]') return locals() 
> @auth.requires_membership('Admin') def edit_home(): home = 
> db.home(request.args(0)) or redirct(URL('parks')) form = 
> crud.update(db.home, home, next='home/[id]') return locals()
>
> {{extend 'layout.html'}} <h1>Create A New Park</h1> {{=form}} 
>
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 205, in restricted
>   File 
> "/Applications/web2py.app/Contents/Resources/applications/pages/controllers/appadmin.py"
>  <http://127.0.0.1:8000/admin/default/edit/pages/controllers/appadmin.py>, 
> line 433, in <module>
>   File "gluon/globals.py", line 173, in <lambda>
>   File 
> "/Applications/web2py.app/Contents/Resources/applications/pages/controllers/appadmin.py"
>  <http://127.0.0.1:8000/admin/default/edit/pages/controllers/appadmin.py>, 
> line 128, in insert
>   File "gluon/sqlhtml.py", line 1089, in accepts
>   File "gluon/html.py", line 1841, in accepts
>   File "gluon/html.py", line 781, in _traverse
>   File "gluon/html.py", line 781, in _traverse
>   File "gluon/html.py", line 781, in _traverse
>   File "gluon/html.py", line 781, in _traverse
>   File "gluon/html.py", line 788, in _traverse
>   File "gluon/html.py", line 1606, in _validate
>   File "gluon/validators.py", line 2485, in __call__
> TypeError: 'str' object is not callable
>
>
> Thanks for the help.
>
> -Brandon
>
>
> On Monday, May 21, 2012 2:59:17 PM UTC-6, Anthony wrote:
>>
>> Can you inspect the database directly (not using web2py)? Is there in 
>> fact a "yearstring" field in the "home" table of the database, and if so, 
>> is there a NOT NULL constraint on it.
>>
>> Anthony
>>
>> On Monday, May 21, 2012 3:40:14 PM UTC-4, Brandon Reynolds wrote:
>>>
>>> How do I insert the value into that yearstring field? I understand i got 
>>> the key error because of the field not being defined. I was trying that 
>>> only as a troubleshooting step to see what happened. Should i make a 
>>> yearstring field in the db and then just assing it a default value? Or how 
>>> else to i get the value into that field? I also have another form that 
>>> works fine on the site and it doesn't have yearstring field. Please advise.
>>>
>>> On Monday, May 21, 2012 12:07:42 PM UTC-6, Anthony wrote:
>>>>
>>>> In your model, there is no "yearstring" field defined (there is a 
>>>> "year" field, though) -- so that's why you get a key error when trying to 
>>>> set db.home.yearstring.default. You might be getting the integrity error 
>>>> because the database itself does include a "yearstring" field (with a 
>>>> notnull requirement), and you are not inserting any value for that field.
>>>>
>>>> Anthony
>>>>
>>>> On Monday, May 21, 2012 1:08:25 PM UTC-4, Brandon Reynolds wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I am new to web2py and pretty new to programming in general. I am 
>>>>> getting the following error when trying to insert a new record with a 
>>>>> form 
>>>>> made with crud.create:
>>>>>
>>>>> <class 'sqlite3.IntegrityError'> home.yearstring may not be NULL
>>>>>
>>>>> I have nothing in my model/view/controllers at all that mentions the 
>>>>> year string. I tried to set yearstring a default value 
>>>>> with db.home.yearstring.default = "0" but then got a key error that year 
>>>>> string was not defined. Here is my controller for this view:
>>>>>
>>>>> @auth.requires_membership('Admin')
>>>>> def new_home():
>>>>>     db.home.pid.default = request.args(0) or redirect(URL('parks'))
>>>>>     db.home.price.default = "$0000.00"
>>>>>     form = crud.create(db.home, next='home/[id]')
>>>>>     return locals()
>>>>>
>>>>> Here is the model for this controller:
>>>>>
>>>>> db.define_table('home', 
>>>>> Field('pid', notnull=True),
>>>>> Field('lot', 'string'),
>>>>> Field('year', 'string', requires=IS_NOT_EMPTY()),
>>>>> Field('make', 'string'),
>>>>> Field('model', 'string'),
>>>>> Field('for_sale', 'boolean', default=True),
>>>>> Field('beds', 'string', requires=IS_NOT_EMPTY()),
>>>>> Field('baths', 'string', requires=IS_NOT_EMPTY()),
>>>>> Field('fridge', 'boolean'),
>>>>> Field('stove', 'boolean'),
>>>>> Field('dishwasher', 'boolean'),
>>>>> Field('microwave', 'boolean'),
>>>>> Field('washer', 'boolean'),
>>>>> Field('dryer', 'boolean'),
>>>>> Field('photo1', 'upload'),
>>>>> Field('photo2', 'upload'),
>>>>> Field('photo3', 'upload'),
>>>>> Field('photo4', 'upload'),
>>>>> Field('photo5', 'upload'),
>>>>> Field('price', 'string' , requires=IS_NOT_EMPTY()),
>>>>> Field('description', 'text', requires=IS_NOT_EMPTY()))
>>>>>
>>>>> Also here is the traceback.
>>>>>
>>>>> Traceback (most recent call last):
>>>>>   File "gluon/restricted.py", line 205, in restricted
>>>>>   File 
>>>>> "/Applications/web2py.app/Contents/Resources/applications/pages/controllers/view.py"
>>>>>  <http://127.0.0.1:8000/admin/default/edit/pages/controllers/view.py>, 
>>>>> line 110, in <module>
>>>>>   File "gluon/globals.py", line 173, in <lambda>
>>>>>   File "gluon/tools.py", line 2575, in f
>>>>>   File 
>>>>> "/Applications/web2py.app/Contents/Resources/applications/pages/controllers/view.py"
>>>>>  <http://127.0.0.1:8000/admin/default/edit/pages/controllers/view.py>, 
>>>>> line 88, in new_home
>>>>>   File "gluon/tools.py", line 3172, in create
>>>>>   File "gluon/tools.py", line 3115, in update
>>>>>   File "gluon/sqlhtml.py", line 1274, in accepts
>>>>>   File "gluon/dal.py", line 6829, in insert
>>>>>   File "gluon/dal.py", line 928, in insert
>>>>> IntegrityError: home.yearstring may not be NULL
>>>>>
>>>>>
>>>>> What is this error ad how can i get around it?
>>>>>
>>>>

Reply via email to