Thanks Anthony.
Yahaaa. Now it works. As u suggested I have successfully  changed settings 
of lazy_tables to False and it works:
db = DAL('sqlite://se2.sqlite',check_reserved=['postgres', 
'postgres_nonreserved'],pool_size=10,lazy_tables=False, migrate=True, 
fake_migrate=False)
 now I got right results:
>>> db.ta._fields                                                           
                                                                           
['id', 'f1', 'newfield']

Anthony I wonder what is wrong in the adding fields to the table in this 
way? What is the maximum number of fields I can add db table?

Web2py community is the best one I have every entered in my life!!! 
Anthony, thanks again for your help!!!



On Friday, February 7, 2014 7:30:42 PM UTC+3, Anthony wrote:
>
> Looks like it's an issue with lazy_tables. I'll look into it, but for now, 
> give it a try by turning off lazy_tables.
>
> Anthony
>
> On Friday, February 7, 2014 8:45:46 AM UTC-5, Anthony wrote:
>>
>> Hmm, works for me. What version of web2py are you using?
>>
>> On Friday, February 7, 2014 8:07:10 AM UTC-5, Andrey K wrote:
>>>
>>> Thanks Anthony for your concise answer!
>>> I have tried it in the app code -  it did not work, giving me no error. 
>>> I have tried your code in the terminal and it looks the code does not 
>>> create new table field. Any idea why it does not work? Maybe its my db 
>>> settings? I use sqlite db. Your help would very helpful to me as all my 
>>> app dependent on this function. 
>>>
>>> Here is my trial in a terminal:
>>>
>>> >>> from gluon import DAL, Field
>>> >>> db = DAL('sqlite://se2.sqlite',check_reserved=['postgres', 
>>> 'postgres_nonreserved'],pool_size=10,lazy_tables=True, migrate=True, 
>>> fake_migrate=False) 
>>>
>>> >>> ta_args = dict(format='%(f1)s')                                     
>>>                                                                             
>>>           
>>> >>> db.define_table('ta',    Field('f1', 'string'),    **ta_args)
>>> >>> db._tables
>>> ['ta']
>>> >>> db.ta._fields                                                       
>>>                               
>>> ['id', 'f1']
>>> #if understand correctly here I am trying to add new field 'newfield' to 
>>> the ta table.
>>> >>> db.define_table('ta', db.ta,Field('newfield', 'string', default = 
>>> 'abc'),redefine=True, **ta_args)                       
>>> >>> db.ta._fields 
>>> #it giving me no change in db.table field list                           
>>>                                                          
>>> ['id', 'f1']
>>>
>>> On Thursday, February 6, 2014 4:41:29 PM UTC+3, Anthony wrote:
>>>>
>>>> The safest way is probably to redefine the whole table.
>>>>
>>>> *models/dp.py:*
>>>>
>>>> tA_args = dict(format='%(f1)s', ...)
>>>> db.define_table('tA',
>>>>     Field('f1', 'string'),
>>>>     **tA_args)
>>>>
>>>> *controllers/default.py:*
>>>>
>>>>     db.define_table('tA', db.tA,
>>>>         Field('newfield'),
>>>>         redefine=True, **tA_args)
>>>>
>>>> Anthony
>>>>
>>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to