Hello everyone,

I'm just starting to use pylons so maybe what i have done will be
quite stupid but i'm still asking ^^

So i want to be able to use about 3/4 databases for my website all on
the same mysql server, i have modified some file for my project and i
would like to know if it's the right way to do it ... or not

--- development.ini ---
replaced : sqlalchemy.url = sqlite:///%(here)s/development.db
by : ({'name' : 'characters', 'sqlalchemy.url' : 'mysql://
login:passw...@localhost/characters'}, {'name' : 'realm',
'sqlalchemy.url' : 'mysql://login:passw...@localhost/realmd'})

--- environment.py ---
replaced :
    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)
by:
    dbs = eval(config['sqlalchemy.databases'])
    for db in dbs:
        engine = engine_from_config(db, 'sqlalchemy.')
        init_model(engine, db['name'])

--- meta.py ---
replaced:
    everything
by:
class metaObj(object):
    def __init__(self):
        self.engine = None
        self.Session = scoped_session(sessionmaker())
        self.metadata = MetaData()

metas = {'realm' : metaObj(), 'characters' : metaObj()}

--- model/__init__.py ---
replaced :
def init_model(engine):
    meta.Session.configure(bind=engine)
    meta.engine = engine
by:
def init_model(engine, name):
    metas[name].Session.configure(bind=engine)
    metas[name].engine = engine

And the worst for the end ... (this is just a bad hack to try if what
i've done before was working)

--- base.py ---
replaced by :
        #try:
        return WSGIController.__call__(self, environ, start_response)
        #finally:
            #meta.Session.remove()

Thank you ;)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to