Ticket #1500 (new bug)

Opened 7 years ago

Last modified 7 years ago

Context manager & next_method conflict?

Reported by: sprat Owned by: apoirier
Priority: minor Component: renderers
Version: 0.3.0 Keywords: next_method context manager
Cc:

Description

It seems there's a problem when combining "context manager style" render functions and next_method for calling inherited views. Here is a minimal test case that exhibits the problem (no Hello World show in the browser):

import os

from nagare import presentation


class App(object):
    pass


@presentation.render_for(App)
def render(self, h, *args):
    h << 'Hello world!'
    return h.root


class InheritedApp(App):
    pass


# does not work
@presentation.render_for(InheritedApp)
def render(next_method, self, h, comp, *args):
    with h.div(class_='wrapper'):
        h << next_method(self, h, comp, *args)
    return h.root


# works
#@presentation.render_for(InheritedApp)
#def render(next_method, self, h, comp, *args):
#    return h.div(next_method(self, h, comp, *args), class_='wrapper')


# ---------------------------------------------------------------

app = InheritedApp

Hopefully, there's a workaround: a "functional style" render function.

Change History

comment:1 Changed 7 years ago by sprat

Finally, I'm not sure this should be considered as a bug. The next_method call change the same dom tree as the one used in the InheritedApp? render function, so we shouldn't attach the next_method result to the current dom tree or we should provide another renderer to the next_method call. Like this:

with h.div(class_='wrapper'):
    next_method(self, h, comp, *args)

or

with h.div(class_='wrapper'):
    h << next_method(self, h.new(), comp, *args)
Note: See TracTickets for help on using tickets.