On Feb 3, 10:29 pm, pkraus <
paul.kr...@gmail.com> wrote:
> I have a model setup to represent a customer.
> I have a method on that model that returns a representation of that
> customer as a dictionary.
> In my controller i convert that dictionary to json and feed it to a page
> via json.
>
> On my page i have it setup so that when a field is updated I update that
> field using ajax.
>
> In the controller i get my customer, set the new value an the field and
> then I want to return from the ajax call a new version of the customer as
> json.
>
> The problem is that the changes haven't been committed to the database and
> even thought the field has been changed when i call Customer.as_dict
That looks like a @classmethod. Wouldn't customer.as_dict (a normal
method with self, not cls) do the right thing? Don't you already have
a customer object with the correct values? I realize you'd need to
fiddle the names to add a second as_dict method.
If you're retrieving a Customer object through the SQLAlchemy session
using the primary key, I'd expect SQLAlchemy to return the modified
object. You might check that also.
(Does this make sense or did I totally misunderstand what you're
doing.)