how do i connect to another app sqlite database?


2013/6/6 Anthony <[email protected]>

> If you import the module from B within A, the B module doesn't get the
> "current" object from the B app -- that object is created when the db.py
> model file of the B app gets executed, which is not happening here. If you
> want to use the db from app B, you could either create the DAL connection
> object in the module as well, or create the DAL connection in app A but
> just use the app B modules to handle creation of the table definitions.
>
> Anthony
>
>
> On Thursday, June 6, 2013 10:37:36 AM UTC-4, Ramos wrote:
>
>> Well, seems an easy task but i´m stuck
>>
>> How can i get in app A a sqlform.smartgrid(db.auth_**user) from app B?
>> db is B's db
>>
>> in app A i call the app B module
>>
>> from applications.B.modules.funcs import *
>> def calmais():
>>     return mais()
>>
>>
>>
>> In app B
>> *in db.py*
>> current.db = db
>>
>>
>> *i have a module funcs.py*
>> inside...
>> def mais():
>>     db=current.db
>>     grid=SQLFORM.smartgrid(db.**auth_user)
>>     return grid
>>
>>
>> i get the error
>>
>>  File "applications\B\modules\funcs.**py", line 6, in mais
>>
>>
>>
>>     db=current.db
>> AttributeError: 'thread._local' object has no attribute 'db'
>>
>> why cant i just use db inside a module and have to use current.db trick?
>>
>>
>>
>>
>> 2013/6/6 António Ramos <[email protected]>
>>
>>> gotcha
>>> from applications.myapp.modules.**funcs import func
>>>
>>> Nice !
>>>
>>>
>>> 2013/6/6 António Ramos <[email protected]>
>>>
>>>> How do i import a module from another app?
>>>>
>>>>
>>>> 2013/6/5 Niphlod <[email protected]>
>>>>
>>>> and.... nobody stops you to call other apps pages inside your "master"
>>>>> one, e.g., using LOAD, and "elect" a master app to take care of
>>>>> authorization with CAS.
>>>>>
>>>>> On Wednesday, June 5, 2013 7:21:39 PM UTC+2, Ramos wrote:
>>>>>
>>>>>> I have to check this ..
>>>>>>
>>>>>> *But you can put your SQLFORM in a module function and import it
>>>>>> within
>>>>>> any application.*
>>>>>>
>>>>>>
>>>>>> 2013/6/5 Vinicius Assef <[email protected]>
>>>>>>
>>>>>>> So, it doesn't make sense.
>>>>>>>
>>>>>>> But you can put your SQLFORM in a module function and import it
>>>>>>> within
>>>>>>> any application.
>>>>>>>
>>>>>>> On Wed, Jun 5, 2013 at 2:06 PM, António Ramos <[email protected]>
>>>>>>> wrote:
>>>>>>> > it was app, not database i wanted to write
>>>>>>> >
>>>>>>> > table = SQLFORM.grid(app,
>>>>>>> >
>>>>>>> >                   query,
>>>>>>> >                   links=links,
>>>>>>> >                   deletable=False,
>>>>>>> >                   editable=False,
>>>>>>> >                   create=False
>>>>>>> >                  )
>>>>>>> >
>>>>>>> >
>>>>>>> >
>>>>>>> > 2013/6/5 Vinicius Assef <[email protected]>
>>>>>>>
>>>>>>> >>
>>>>>>> >> The query parameter already has the database you wish.
>>>>>>> >>
>>>>>>> >> On Wed, Jun 5, 2013 at 1:41 PM, António Ramos <[email protected]
>>>>>>> >
>>>>>>>
>>>>>>> >> wrote:
>>>>>>> >> > Hello,
>>>>>>> >> > One of the things i have to do daily using Lotus Notes in my
>>>>>>> company is
>>>>>>> >> > to
>>>>>>> >> > have a form to show a grid with documents from another
>>>>>>> app/table.
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> > Short story
>>>>>>> >> > First , years ago, i created an app to manage all quality
>>>>>>> certificates
>>>>>>> >> > issued to the clients.
>>>>>>> >> > About 5000 a year total.
>>>>>>> >> > I have about 70.000 in that database.
>>>>>>> >> >
>>>>>>> >> > Second, after some time ,i created another database to record
>>>>>>> every
>>>>>>> >> > visit to
>>>>>>> >> > the clients.
>>>>>>> >> >
>>>>>>> >> > Third ,recently i had to create another app to manage Quality
>>>>>>> issues/Non
>>>>>>> >> > conformities.
>>>>>>> >> > Another context, another app.another Acess Control List,etc
>>>>>>> >> >
>>>>>>> >> > In the end, our Top executives saw the need to manage all of
>>>>>>> the clients
>>>>>>> >> > documents in one single screen.At last i created an ap to
>>>>>>> manage THE
>>>>>>> >> > CLIENT!!!
>>>>>>> >> > There was no  need to rewrite my apps or to import data,etc.
>>>>>>> >> > Lotus Notes can embed a view to show documents in another
>>>>>>> database with
>>>>>>> >> > just
>>>>>>> >> > the mouse click.
>>>>>>> >> > It was very easy inside Lotus Notes environment.In just some
>>>>>>> minutes it
>>>>>>> >> > was
>>>>>>> >> > DONE!!!
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> > I wish web2py could have something like this
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> > table = SQLFORM.grid(database,
>>>>>>> >> >
>>>>>>> >> >                   query,
>>>>>>> >> >                   links=links,
>>>>>>> >> >                   deletable=False,
>>>>>>> >> >                   editable=False,
>>>>>>> >> >                   create=False
>>>>>>> >> >                  )
>>>>>>> >> >
>>>>>>> >> > As Auth can be the same for the entire server apps , it would
>>>>>>> be nice to
>>>>>>> >> > share data as easily as possible.
>>>>>>> >> > That is a important need for an enterprise framework.
>>>>>>> >> >
>>>>>>> >> > Best regards
>>>>>>> >> >
>>>>>>> >> > António
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >> > --
>>>>>>> >> >
>>>>>>> >> > ---
>>>>>>> >> > 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.
>>>>>>>
>>>>>>> >> > For more options, visit https://groups.google.com/**grou**
>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>> >> >
>>>>>>> >> >
>>>>>>> >>
>>>>>>> >> --
>>>>>>> >>
>>>>>>> >> ---
>>>>>>> >> 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.
>>>>>>>
>>>>>>> >> For more options, visit https://groups.google.com/**grou**
>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>> >>
>>>>>>> >>
>>>>>>> >
>>>>>>> > --
>>>>>>> >
>>>>>>> > ---
>>>>>>> > 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.
>>>>>>>
>>>>>>> > For more options, visit https://groups.google.com/**grou**
>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>> >
>>>>>>> >
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> ---
>>>>>>> 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.
>>>>>>>
>>>>>>> For more options, visit 
>>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>>> .
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>  --
>>>>>
>>>>> ---
>>>>> 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.
>>>>> For more options, visit 
>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>  --
>
> ---
> 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/groups/opt_out.
>
>
>

-- 

--- 
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/groups/opt_out.


Reply via email to