On Sep 29, 2013, at 8:41 AM, Roman Iten <roman.i...@sg-unteraegeri.ch> wrote:

> Hi
> 
> I started a pyramid project using the alchemy scaffold (includes 
> ZopeTransactionExtension to scope sessions to requests, see [1]).
> 
> Trying to insert many 'shots' into a MySQL database with a single SQL 
> statement, I implemented the following view:
> 
> DBSession = scoped_session(
>    sessionmaker(extension=ZopeTransactionExtension()))
> 
> @view_config(route_name='upload')
> def upload_view(request):
>    shotlist = []
>    shotlist.append(Shot(score=92))
>    shotlist.append(Shot(score=82))
>    shotlist.append(Shot(score=99))
>    shotlist.append(Shot(score=78))
> 
>    # The transaction is only committed if this line is enabled:
>    # DBSession.add(Shot(score=42))
> 
>    DBSession.execute(Shot.__table__.insert(),
>                      [shot.__dict__ for shot in shotlist])
> 
>    return Response('OK')
> 
> But the transaction is not committed. I discovered that the transaction is 
> committed only if I call add() on DBSession (all five shots are inserted 
> then)...

I always thought the zope extension called session.commit() unconditionally, 
perhaps there's some setting for that.  if none of the pyramid gurus speaks up 
here try emailing the pyramid list.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to