sqlalchemy / sqlalchemy/mako

`next.body()` raises an error when not called in an inherited context

Open
#252 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
459
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Migrated issue, originally created by jvanasco (@jvanasco)

I noticed this while bugfixing some parent templates in an inheritance chain.

The following is raised when the template containing ${next.body()} is called directly:

AttributeError: 'builtin_function_or_method' object has no attribute 'body'

While this makes sense, I think there are better ways to handle it:

a_ raise a custom error that says "You're calling this direct, must inherit"
b_ [preferred] just return an empty string value when there is no next

I think the latter behavior is better for introductory users.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the direct template call containing ${next.body()} described in the issue, then trace how next.body() is resolved outside an inheritance chain. The change is done when that direct call returns an empty string, with a regression test covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.