The NewContent.data() method retrieves database rows. The render method for this class creates a form out of each row. When the form is submitted the user can input a new value for the Content field of the database row.
In ConfigureContent.answer() I attempt to update the database row. However even though the database row is updated in memory, (1) database.session does not know that the session is dirty and should be commited (2) the database does not get updated. How can I alter this code to update the database? I'm aware that I could query the database and update, but that seems absolutely wasteful as I already have the object here. class NewContent(object): def __init__(self): pass def data(self): return database.session.query( models.OBFL_Log_ParsingErrors).filter( models.OBFL_Log_ParsingErrors.Type_Of_Record == 'Error') def config(self, comp, dbrow): print "Calling config" comp.becomes(ConfigureContent(dbrow)) #r = comp.call(util.Ask("does she love me?")) #r = comp.becomes(util.Ask("does she love me?")) print "ask does finish?. " @presentation.render_for(NewContent) def render(self, h, comp, *args): for le in self.data()[:100]: #print "rowdict={0}".format(row) with h.div: with h.form.post_action(self.config, comp, le): h << h.input(type='Submit', value='Delete') h << h.input(value=le.File_ID, disabled=True) h << h.input(value=le.File_Name, disabled=True) h << h.input(value=le.Line_Start, disabled=True) h << h.input(value=le.Content, disabled=True) h << h.input(type='Submit', value='Configure') return h.root class ConfigureContent(object): """Ask the user to enter a line of text The text entered is answered """ def __init__(self, database_row): """Initialization In: - ``msg`` -- message to display """ self.dbrow = database_row print "Config init complete" @staticmethod def cleancheck(): print "Dirty check {0}".format(database.session.dirty) def answer(self, comp, r): self.cleancheck() print "R={0}. dbrowdict={1}".format( r(), self.dbrow.__dict__) self.dbrow.Content = r() print "R={0}. dbrowdict={1}".format( r(), self.dbrow.__dict__) self.cleancheck() -- You received this message because you are subscribed to the Google Groups "Nagare users" group. To unsubscribe from this group and stop receiving emails from it, send an email to nagare-users+unsubscr...@googlegroups.com. To post to this group, send email to nagare-users@googlegroups.com. Visit this group at http://groups.google.com/group/nagare-users. For more options, visit https://groups.google.com/d/optout.