At work we've pushed our SQLAlchemy model (well, part of it anyways)
into it's own library which both our web front end and our command
line scripts depend on.  Pros and cons, definitely.

Toph


On 3/29/07, Christoph Haas <[EMAIL PROTECTED]> wrote:
>
> Dear list...
>
> I (still) work on my task to do some database maintainance on the tables
> that I use in Pylons as models. So it sounds clever to reuse my
> configuration (.ini file) to connect to the database and get access to my
> sqlalchemy-mapped classes. The only solution I have so far looks like:
>
> -------------------------------------------------------------
> import paste.deploy
> import pylons.database
> import sqlalchemy
> import myproject.models as model
>
> app_conf = paste.deploy.appconfig('config:development.ini',
>     relative_to='.')
> paste.deploy.CONFIG.push_thread_config({'app_conf':app_conf})
> engine = pylons.database.create_engine()
>
> print model.MyTestModel.get_by(name='John Doe')
> -------------------------------------------------------------
>
> Can someone please comment on whether this can be done better? I feel dirty
> to run paste.deploy.CONFIG.push_thread_config. I'm not even in a thread
> context - just want to run a plain Python script. But without it I'm
> harrassed by this error:
>
> TypeError: No configuration has been registered for this process or thread
>
> How do I properly access my lib/*.py modules and models/__init__.py models
> outside of the running Pylons application? I couldn't find anything about
> it in the docs. TIA.
>
>  Christoph
>
> >
>

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