On Dec 19, 2007 11:49 AM, Ben Bangert <[EMAIL PROTECTED]> wrote:
> On Dec 18, 2007, at 1:44 AM, Christoph Haas wrote:
>
> > It's bad enough that I have to copy the "SQLAlchemy in a hurry"
> > article
> > for every project. I wouldn't mind if Pylons came with a tighter
> > integration of SQLAlchemy just like we had with pylons.database.
> > And be it that the "in a hurry" setup is put into model/__init__.py
> > and
> > commented out by default.
>
> We plan on having a prompt during creation of new templates, that asks
> you if you want the SQLAlchemy 0.4. I'll see if I can get that added
> today actually, its ticket:
> http://pylonshq.com/project/pylonshq/ticket/328

That looks cool except I'd like the template to have
init_model(engine) rather than the pylons.g.engine.
That makes it easier to import the model anytime, and to use it
without depending on Pylons/config/g.
"Making a Pylons Blog" shows the structure.

http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog

The only undocumented parts are:
- For multiple databases, pass multiple args to init_model, and use
sessionmaker(binds=) if necessary.
- If reflecting, put the table defs inside init_model.
- How to split large models into several modules.  (Put the metadata
in a separate module, and perhaps the table definitions with it.  Put
Session in __init__, and have init_model copy Session into the ORM
other modules for convenience.  This breaks if you reload the ORM
module in "paster shell": you have to copy the Session again manually
or re-run init_model.  But it does avoid circular imports.  There may
be a better way, but that need not affect the application template,
which is just to get you started with a small model.)

-- 
Mike Orr <[EMAIL PROTECTED]>

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

Reply via email to