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?
On Apr 26, 2010, at 1:52 AM, Diez B. Roggisch wrote:
> On Monday 26 April 2010 09:56:08 Todd Blanchard wrote:
>> Its vanilla TG 2.1(latest) atop postgresql + gis with sqlalchemy and I've
>> done nothing fancier than enable the admin via
>>
>> admin = AdminController(model, DBSession, config_type=MyAdminConfig)
>>
>> however, all attempts to create new records fail silently. No error page,
>> nothing in the log file to indicate that it didn't work, but it didn't
>> work.
>>
>> That DBSession is the one imported from model. I'm stumped, this worked in
>> an earlier release.
>
> What about the BEGIN/COMMIT?
>
> 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.
>
--
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.