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)
---------------------------------------------------------------------------
sqlalchemy.exceptions.InvalidRequestError                       Traceback (most 
recent call last)

/home/chaas/projekte/pylons/phonebook/<ipython console>

/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py in get(self, ident, 
**kwargs)
    101             return ret
    102         key = self.mapper.identity_key(ident)
--> 103         return self._get(key, ident, **kwargs)
    104
    105     def load(self, ident, **kwargs):

/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py in _get(self, key, 
ident, reload, lockmode)
    945         try:
    946             statement = self.compile(self._get_clause, 
lockmode=lockmode)
--> 947             return self._select_statement(statement, params=params, 
populate_existing=reload, version_check=(lockmode is not None))[0]
    948         except IndexError:
    949             return None

/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py in 
_select_statement(self, statement, params, **kwargs)
    953         if params is None:
    954             params = {}
--> 955         return self.execute(statement, params=params, **kwargs)
    956
    957     def _should_nest(self, querycontext):

/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py in execute(self, 
clauseelement, params, *args, **kwargs)
    853         """
    854
--> 855         result = self.session.execute(self.mapper, clauseelement, 
params=params)
    856         try:
    857             return self.instances(result, **kwargs)

/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py in execute(self, 
mapper, clause, params, **kwargs)
    181         resources of the underlying ``Connection``, otherwise its a 
no-op.
    182         """
--> 183         return self.connection(mapper, 
close_with_result=True).execute(clause, params, **kwargs)
    184
    185     def scalar(self, mapper, clause, params, **kwargs):

/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py in connection(self, 
mapper, **kwargs)
    168             return self.transaction.connection(mapper)
    169         else:
--> 170             return self.get_bind(mapper).contextual_connect(**kwargs)
    171
    172     def execute(self, mapper, clause, params, **kwargs):

/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py in get_bind(self, 
mapper)
    270             e = mapper.mapped_table.engine
    271             if e is None:
--> 272                 raise exceptions.InvalidRequestError("Could not locate 
any Engine bound to mapper '%s'" % str(mapper))
    273             return e
    274

InvalidRequestError: Could not locate any Engine bound to mapper 
'Mapper|Contact|contacts'

*************************************************************************

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?

 Christoph


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
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