I need to update a (series of) tables from a HTML form with rows of
data. Some rows are new, and some are edits of existing data. First,
here's my query:
current_account_id = ...
trustees = db.query(model.Trustee).with_labels().filter
(model.Trustee.account_id == account.id).filter(model.Trustee.category
== 'T').order_by(model.Trustee.seq).all()
In the Mako template, fields look like this:
%for cnt,trustee in enumerate(trustees):
%if hasattr(trustee, 'trustee_id'):
<input type="hidden" name="trustee.${cnt}.trustee_id" value="$
{trustee.trustee_id}" />
%endif
<input type="hidden" name="trustee.${cnt}.first_name" value="$
{trustee.first_name}" />
.....
%endfor
Existing rows have an ID field.
Can someone provide an example of SQLAlchemy commands to update rows
when they exist and insert rows otherwise? Perhaps based on whether
trustee_id field exists in the HTML form (request.params)?
Many thanks.
Edgar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---