I have a module named Types that stores all of the SQLAlchemy definitions for 
every table in our databases.  Near the top of Types.py is:

    dbh = sqlalchemy.create_engine('postgres://', creator=PostgreSQL.connect2)
    dbh.echo = False
    metadata = sqlalchemy.MetaData(dbh)
    # session = orm.create_session()
    session = None

where PostgreSQL.connect2 is a function from another module that returns a 
connection to our database.  This is followed by about 100 class, table, and 
mapper definitions.  Now, in a TG controller module, I have:

    from turbogears.database import session
    from Daycos.Core import Types

    [...]

    @expose()
    def method(self):
        shipinfo = session.query(Types.Ship).filter_by(shipid=shipid)

How can this possibly work?  Although the Types module connects to our 
database, that session object is coming from TurboGears - and I am 100% sure 
that TG is configured to use a SQLite database.

This came about because I'm trying to figure out why this code never actually 
updates the database:

    shipinfo.destincd = 'HI CAN HAZ IT'
    session.save_or_update(shipinfo)
    session.commit()
    session.flush()
    session.close()

At this point I'm lost and floundering.  What's going on here?
-- 
Kirk Strauser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to