Kirk Strauser schrieb:
> On Tuesday 23 September 2008 11:40:16 Kirk Strauser wrote:
> 
>> 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.
> 
> In this situation, I have no idea what happens with the SQLite settings I 
> configured in dev.cfg, whether they were replaced or somehow augmented so 
> that 
> both databases are now bound to the session.

You can find out exactly what TurboGears (1.1) does by looking at the
source of the turbogears.database module. If you are using SA >= 0.4 the
relevant lines are 71 - 84:

    def create_session():
        """Create a session ...

        """
        if not metadata.is_bound():
            bind_metadata()
        return sqlalchemy.orm.create_session()

    try:
        session = sqlalchemy.orm.scoped_session(create_session)
        mapper = session.mapper
    except AttributeError: # SQLAlchemy < 0.4
        ...

and 49 - 69:

    def bind_metadata():
        """Connect SQLAlchemy to the configured database(s)."""
        if metadata.is_bound():
            return

        alch_args = dict()
        for k, v in config.config.configMap["global"].items():
            if "sqlalchemy" in k:
                alch_args[k.split(".")[-1]] = v

        dburi = alch_args.pop('dburi')
        if not dburi:
            raise KeyError("No sqlalchemy database config found!")
        metadata.bind = sqlalchemy.create_engine(dburi, **alch_args)

        ....

(The rest of the code in this function is only relevant if you have
dburi's of the form 'package.dburi = ...'.)

The code in the 1.0 branch is equivalent.


Chris

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