Muchas gracias,
   Tengo algo parecido referenciando a las funciones correspondientes antes 
de definir las tablas dentro del módulo si hay claves ajenas.
Un saludo,

(Thank you
   I have something similar with references to the functions before 
defining tables in the module if there are foreign keys. 
Cheers,)

On Saturday, 28 January 2017 14:08:10 UTC, Yoel Benitez Fonseca wrote:
>
> this for example: 
>
>
> https://github.com/yotech/agis/blob/master/app/agis/modules/agiscore/db/grupo.py
>  
>
> Not a complete correct example, but can pin/ping the idea 
>
> 2017-01-28 9:05 GMT-05:00 Yoel Benitez Fonseca <yben...@gmail.com 
> <javascript:>>: 
> > sorry on 1.- sould say: 
> > 
> > 1.- Pass your models definitions to modules and packages on ``modules`` 
> > 
> > 2017-01-28 9:04 GMT-05:00 Yoel Benitez Fonseca <yben...@gmail.com 
> <javascript:>>: 
> >> I have being there :-/ ... what i do was: 
> >> 
> >> 1.- Pass your models definitions to models and packages on ``modules`` 
> >> 2.- In the modules put each table definition on a method, for example: 
> >> 
> >> define_tables(): 
> >>     db = current.db 
> >>     if not hasattr(db, 'some_table'): 
> >>         db.define_table('some_table', ....) 
> >> 
> >> 3.- then whenever a some_other_table depends on some_table, in the 
> >> module corresponding to some_other_table you import the corresponding 
> >> define_tables of some_table and call it to ensure it get defined 
> >> before some_other_table references it. 
> >> 4.- use conditional models, and in the conditional model of a given 
> >> controller you import and call only the one you need. 
> >> 
> >> This way, the imports and define_tables ensure the table definitions 
> >> precedences and work out the needed for you.... the downside of 
> >> passing models definitions  to modules is that u need to reload the 
> >> complete web2py instance... hence, if you are running it trough apache 
> >> it must be restarted for changes to refresh. 
> >> 
> >> Regards, 
> >> 
> >> 
> >> 2017-01-26 7:28 GMT-05:00 Bentorey Hernández Cruz <bento...@gmail.com 
> <javascript:>>: 
> >>> Hi all, 
> >>>     I have a question related to table definitions in modules. I'm 
> working 
> >>> in an app that has more than a hundred tables and I noticed that even 
> using 
> >>> lazy tables it took too much for browsing the site. 
> >>>     I decided to move some of the tables to a module and call them on 
> >>> demand, and the performance improved a lot. 
> >>>     The problem is if there's any way to define new tables from the 
> module. 
> >>> 
> >>>    Whatever I do, I get the error: 
> >>> 
> >>>   ProgrammingError: ('ERROR', '42P01', 'relation "test_t" does not 
> exist') 
> >>> 
> >>> Definition of test_t in module 
> >>>> 
> >>>> from gluon import * 
> >>>> from gluon.dal import Field 
> >>>> def defineTEST(db): 
> >>>>     if 'test_t' not in db: 
> >>>>         db.define_table('test_t', 
> >>>>         Field('bid', 'reference b_t', ondelete='CASCADE'), 
> >>>>         Field('date', 'date'), 
> >>>>         migrate=app_settings.migrate) 
> >>> 
> >>> 
> >>> Code added to 10dbmodel.py in models: 
> >>>> 
> >>>> from app.modules import defineTEST 
> >>>> defineTEST(db) 
> >>> 
> >>> 
> >>>    And the table is not created. 
> >>> 
> >>> Thank you! 
> >>> 
> >>> -- 
> >>> 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+un...@googlegroups.com <javascript:>. 
> >>> For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> >> 
> >> -- 
> >> Yoel Benítez Fonseca 
> >> http://redevil.cubava.cu/ 
> >> $ python -c "import this" 
> > 
> > 
> > 
> > -- 
> > Yoel Benítez Fonseca 
> > http://redevil.cubava.cu/ 
> > $ python -c "import this" 
>
>
>
> -- 
> Yoel Benítez Fonseca 
> http://redevil.cubava.cu/ 
> $ python -c "import this" 
>

-- 
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