comp.call() spins browser, comp.becomes() works fine.

9 views
Skip to first unread message

Terrence Brannon

unread,
May 12, 2015, 3:27:03 PM5/12/15
to nagare...@googlegroups.com
The presentation model for NewContent renders each row of database
data into a form. When one of these rows of database data is clicked on, I want to
temporarily replace the component with a util.Ask() instance. But
comp.call() does not do this. Instead the web browser spins forever,
waiting on the server.

By contrast, calling comp.becomes(util.Ask()) works fine.

Why can I not use comp.call() on util.Ask() and have it replace the
entire component of NewContent and then re-render newContent once
util.Ask() returns?

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):
        r = comp.call(util.Ask("does she love me?"))
        #r = comp.becomes(util.Ask("does she love me?"))
        print "Does ask finish?"

@presentation.render_for(NewContent)
def render(self, h, comp, *args):

    for le in self.data()[:100]:
        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


Alain Poirier

unread,
May 12, 2015, 5:55:16 PM5/12/15
to nagare...@googlegroups.com
The 'config()' callback modifies the components graph by invoking the 'call()'
method of 'comp'.

Such a callback can only be registered on a 'a', 'input(type="submit")' or
'input(type="image")' element. This is the meaning of the warning at
http://www.nagare.org/trac/wiki/CallbacksAndForms#callback-order

So, simply move the registration of the callback from the 'form' element to
the submit button:

with h.form:
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').action(self.config, comp, le)

('submit' in lower cases)


BTW, note you can also now register a different callback to the
h.input(type='submit', value='Delete') button.

Reply all
Reply to author
Forward
0 new messages