<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate(self, blueprint, context, interactive=True):
 """Generate a blueprint within this application."""

        if not isinstance(blueprint, Blueprint):
            bp = self.blueprints.get(blueprint)
            if not bp:
                raise ValueError('%s is not a valid blueprint' % blueprint)
            blueprint = bp

        self.stdout.write(
            style.format_command(
                'Generating',
                blueprint.full_name
            )
        )
        generator = Generator(
            self,
            blueprint,
            context,
            interactive=interactive
        )
        result = generator.generate()
        if blueprint.name == 'init':
            # try re-setting the name
            self.refresh()
        return result