3 messages in com.googlegroups.pylons-discussRe: SAContext and "paster shell"
FromSent OnAttachments
Christoph Haas16 Jul 2007 13:35 
Edin Salkovic16 Jul 2007 14:20 
Christoph Haas16 Jul 2007 14:32 
Subject:Re: SAContext and "paster shell"
From:Edin Salkovic (edin@public.gmane.org)
Date:07/16/2007 02:20:34 PM
List:com.googlegroups.pylons-discuss

On 7/16/07, Christoph Haas
<email-Nf+wZpSdgwd6//Dw7l@public.gmane.org> 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