On 7/16/07, Christoph Haas <[EMAIL PROTECTED]> wrote:
>
> Dear list,
>
> I'm on SQLAlchemy 0.3.9 and SAContext 0.3.1 now with Pylons 0.9.6-rc1. A
> lot of knowledge is useless now that SQLAlchemy changed quite a few
> things regarding queries and Pylons doesn't have pylons.database any
> longer.
>
> Currently I'm trying to get myself acquainted with a lot of syntax and
> wanted to use the "paster shell" to play around. But when using
> SAContext the way it's described (pydoc sacontext) I just get this error
> when I try to query the database:
>
> *************************************************************************
>
> In [4]: model.sac.query(model.Contact).get(1)
> ---------------------------------------------------------------------------
(...)
> *************************************************************************
>
> Using pylons.database it was formerly necessary to bind the metadata to
> an engine somehow using:
>
>     model.meta.connect(model.session_context.current.bind_to)
>
> What should I do now with SAContext?

Briefly:
See the section "Pylons usage" from sacontext.py (
http://sluggo.scrapping.cc/python/sacontext/sacontext.py ):

The metadata you pass to your model's Tables etc. is sac.metadata, the
session_context is simply sac.session_context

My model/__init__.py
-------------------------
from myapp.lib.sacontext import PylonsSAContext
sac = PylonsSAContext()
# Adds a default engine to sac.
# sac.metadata and sac.session_context use it by default
sac.add_engine_from_config("default")

development.ini
--------------------
sqlalchemy.default.uri = sqlite:///%(here)s/somedb.db

HTH,
Edin

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