Where is the object Stockist instantiated? and where 
is register_product_input called?

On Thursday, 10 October 2013 11:31:59 UTC-5, Matheus Cardoso wrote:
>
> Here is the more complete code from a modulo of mine:
>
> import unittest
> import sys
> import os
> from os import path
>
> sys.path.append('../../../') # we need this to use web2py's modules
>
> from gluon import *
>
> class Stockist(object):
>          def __init__(self):
>               #some instance variable initialization
>
>          def register_product_input(self, item):
>                current.db.stock.insert(product_id=item.id, 
> product_description=item.desc)
>
> The rest of the code is like above, cuz this class is only to db 
> operations in a single table.
>
> On Thursday, October 10, 2013 11:25:39 AM UTC-3, Matheus Cardoso wrote:
>>
>> Hi guys,
>>
>> Sorry if the following question was already answered,  but I could not 
>> find nothing like this in this list, stack or in others lists. Here is the 
>> thing: I wrote some tests that already was working. I got back to the code, 
>> after some time, and then: 'thread._local' object has no attribute (in this 
>> case, the classic 'db'). Here is my code:
>>
>> In models/0.py
>>
>> db = 
>> DAL(db_postgres_url,pool_size=1,check_reserved=['all'],fake_migrate_all=False)
>>
>> from gluon import current
>> current.db = db
>>
>> In module/my_module.py
>>
>> from gluon import *
>> def some_function():
>>       #some db stuff calling current.db
>>
>> However, the 'thread._local' object has no attribute db keeps raising. I 
>> tried other approach like 
>>       
>> In models/0.py
>>
>> db = 
>> DAL(db_postgres_url,pool_size=1,check_reserved=['all'],fake_migrate_all=False)
>>
>> from gluon import current
>> from storage import Storage
>> current.toc = Storage()
>> current.toc.db = db
>>
>> But then, the same error, but with "toc", raises again. Is there any 
>> changes in Web2py that changed this behavior? 
>>
>>
>>
>>
>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to