I found contradictory on this subject but as far as I know the
session.flush() is implicit but the session.save() is explicit. So add
a session.save(d) to your code and everything should work. Perhaps
someone with more experience can give us a little bit of background
knowledge.
On 24 Apr., 17:53, remi jolin <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm using TG 1.0.1 +Sqlalchemy
> Up to today I've always assumed that when I modified an object in a
> "url" method, this object was automatically flushed back to the DB if
> the page generation encountered no errors.
>
> But I must be wrong !!
> Today I wrote a small piece of code to update a data based on the
> information received through the URL like this one :
> @expose('json', allow_json=True)
> def store_info(self, id, info):
> d = MyData.get(id)
> if not d:
> return dict(state="Nok")
> v = d.value
> d.value=info
> return dict(state="OK", prev_value=v)
>
> If I dohttp://xxxx:8080/store_info/1/new_data, I get back the json dict
> but the data is not updated (if I enable the DB engine echo, I can see
> the commit but no update). Is it the normal behavior ?
> It is only updated if I force a flush (session.flush()) before the return.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---