On Mon, Mar 3, 2008 at 2:09 PM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
>   i. how would i access a specific engine to handle transactional
>  stuff ? would that be through a global item or in an object?

init_model() puts the engines as attributes of the 'meta' module.
Your transactional code can read them from there.

>   ii. how would i specify a new object to be using an engine.  does it
>  get a bind too?

With new records It doesn't touch the database until you call
Session.commit() or Session.flush(), so there's where you'll need the
'bind' argument.

If you don't bind the session to an engine and you don't specify a
'bind' argument, you'll get a nice fat exception whenever you access
the database.  That will tell you where you need to put 'bind'
arguments.

>  > Your "configure" engine is a special case because you use it only at
>  > startup.  Your model.init_model() function can use it to populate some
>  > Python object, then let it go out of scope and it will be closed.
>
>  so i don't need to do anything special for it to close?  awesome.
>  under mod_perl i have to do quite a bit to lose the db from the pool.

Well, I don't know for sure, but there's probably a 'engine.close()'
method or such for this purpose.  You could use:

    conn = engine.connect()
    conn.execute(SQL ...)
    sql.execute(bind=conn)
    conn.execute(more SQL...)
    Session.execute(bind=conn)
    conn.close()

To verify that it uses exactly one connection and closes it when you tell it to.

-- 
Mike Orr <[EMAIL PROTECTED]>

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