On Monday 26 April 2010 11:32:55 Todd Blanchard wrote:
> Ah, I had disabled the zope transaction extension and apparently admin uses
> it. Fine, admin works, but now all my other code doesn't.
>
> What's wrong with this:
>
> from model import DBSession
> import transaction
>
> @expose('json')
> def post(self, **kw):
> user = DBSession.query(User).filter(User.user_name ==
> kw['user.login']).one() wkt = 'POINT( %(latitude)s %(longitude)s )' % kw
> breadcrumb = None
> try:
> remote_id_uri = kw['remote_id_uri']
> breadcrumb =
> DBSession.query(Breadcrumb).filter(Breadcrumb.remote_id_uri ==
> kw['remote_id_uri']).one() except NoResultFound, e:
> breadcrumb = Breadcrumb(user_id=user.user_id,
> website_id=current_website_id(),
> timestamp=kw['timestamp'],
> device_id=kw['device_id'],
> geo_location=WKTSpatialElement(wkt),
> remote_id_uri=kw['remote_id_uri'],
> horizontal_accuracy=kw['horizontal_accuracy'],
> vertical_accuracy=kw['vertical_accuracy'],
> speed=kw['speed'],
> course=kw['course'],
> altitude=kw['altitude'],
> heading_accuracy=kw['heading_accuracy'],
> magnetic_heading=kw['magnetic_heading'],
> true_heading=kw['true_heading']
> )
> DBSession.add(breadcrumb)
> transaction.commit()
>
> results = dict()
> results[breadcrumb.remote_id_uri] = dict(id=breadcrumb.id)
>
> return results
>
>
> Apparently I don't actually understand the interaction between DBSession
> and this transaction extension. Previously I disabled the transaction
> extension and just used DBSession.commit() and everything worked great.
> Now I try working with this transaction thing and I get errors like
>
> UnboundExecutionError("Instance <Breadcrumb 0x2342> is not bound to a
> Session; attribute refresh operation cannot proceed" what does that mean?
I'm sorry that I can't be of help here anymore - because for errors of that
kind, we threw away zope.transaction & just rolled out our own (extremely
simple) transaction management.
But I suggest you google this group & sqlalchemy about these problems, AFAIK
they cropped up before.
Diez
--
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en.