I have solved my problem. I was not properly reusing the db (DAL object) in 
my library. Instead, a new DAL connection was being created in some cases. 
Therefore, even though the tables were defined at the pyhton level, auth 
was not really aware of it, and was trying to redefine them.

Facit: make sure that a single db object is used in the models and in any 
external modules.

Thanks for your assistance!
Daniel Gonzalez

On Thursday, October 30, 2014 4:29:26 PM UTC+1, Daniel Gonzalez wrote:
>
> Getting closer to identifying my problem. It seems I am having several 
> problems at once.
>
> First, it seems that migrate_enabled=False prevents not only migrations, 
> but also table creation (am I right here?)
>
> Second: while trying to guess the problems with my application, I am using 
>  the  test script provided. Running manually that script, and at the same 
> time working with pgadmin (that is, manually creating / droping 
> databases/tables), causes serious conflicts with web2py. It seems web2py 
> has its own caching mechanism on the file system for the table definitions 
> (pickled objects?)
>
> I have now clarified that, and to mitigate those problems I am doing: 
> 1. drop database, remove pickled files, restart web2py
> 2. Do not use lazy_tables and enable migrations (this ensures that the 
> tables will be created exactly on the call to define_tables)
> 3. Call .commit(). I have the code to define_tables outside in a module, 
> and according to the manual, no autocommit is performed for modules. The 
> reason I am doing this is that I want to be able to reuse the same code 
> from outside my web2py application, for maintenance/reporting purposes: I 
> have a library with all web2py related functionality, which I can call from 
> the web2py application itself, or simply from an external script.
>
> But still, I see a problem: I can see clearly in the sql.log file that my 
> define_table creates the table as I want, but immediately after, 
> auth.define_tables() modifies that table: drops my fields, adds the 
> standard auth fields.
>
> According to the manual (
> http://web2py.com/books/default/chapter/29/9#Customizing-Auth):
>
> If a table is declared beforeauth.define_tables() it is used instead of 
> the default one
>
> I would expect that Auth sees that auth_user is already defined, skip the 
> definition of that table, and define the other auth tables. But in my case 
> it seems auth is overwrriting the table defintion. Why can this be?
>
> BR,
> Daniel
>
>
> On Thursday, October 30, 2014 1:04:27 PM UTC+1, Anthony wrote:
>>
>> On Thursday, October 30, 2014 7:41:07 AM UTC-4, Leonel Câmara wrote:
>>>
>>> Well lazy_tables=True is the default.
>>>
>>
>> Actually, it does default to False, but that's not the issue here.
>>
>> 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/d/optout.

Reply via email to