Well here's some code:

def tags_link_insert(self, table_id, table_name, tags):
        if not isinstance(table_name, str):
            raise TypeError("table_name must be of type str")
        if not isinstance(tags, (list, tuple)):
            tags = [tags]
        tagstb = self.tags_table
        linkstb = self.links_table
        for item in tags:
            if not isinstance(item, str):
                raise TypeError('tags must be of type str')
            tag_item = self.db(tagstb.tag==item).select(tagstb.id).first()
            tag_id = tag_item['id'] if tag_item else tagstb.insert(tag=item)
            ret = linkstb.insert(table_id=table_id, table_name=table_name,tag_id
=tag_id)

self.db is set in the __init__ as follows, where tdb is set to the defined 
db in db.py after which a call is made to the class:
def __init__(self, tdb, tables, orderby=None, user_signature=False,hmac_key=
None, autopopulate=True):
        self.db = tdb

When I look at ret, I get valid a valid return value, but when I look at 
the database, I can see that no commit was made.

I read about exec_environment, are you saying that I can only access the db 
object through the environment? It seems 
Auth<http://www.web2py.com.ar/examples/static/epydoc/web2py.gluon.tools-pysrc.html#Auth>
 does 
not do this. I may be wrong though?

On Wednesday, July 31, 2013 9:03:17 AM UTC-4, Anthony wrote:
>
> Show some code.
>
> On Tuesday, July 30, 2013 11:19:49 PM UTC-4, Mark Finkelstein wrote:
>>
>> I've been using current to access the db in my modules, but I would like 
>> to modularize my modules a bit so that I don't rely as much on current. I 
>> was wondering why db seems to not be accessible from the modules when 
>> passed by a caller and saved through the init statement. In other words, if 
>> I were to call Module(db) or as in Auth(db), it seems that if the module 
>> isnt able to commit to the db. Auth clearly is able to do this, and I 
>> believe I am following the Auth as an example well enough, but I thought 
>> there might be some peculiarities to modules that I am not aware of as 
>> clearly auth accesses the environment in a special way as well. I dont 
>> think there should be a difference between using self.db or current.db; but 
>> I may be mistaken? It seems when I change current.db to self.db, that is 
>> when problems arise.
>>
>> Thank you in advance!
>>
>

-- 

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