sqlalchemy / sqlalchemy/mako

inheritance chain argument (default values) passing problem

Open
#306 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Maybe it's not a bug at all, but i find argument passing/inheriting in the inheritance chain to be obscure.
Example:

## base.mako
<%page args="x='title',y='description'" />
<base>
	arg 'x': ${x}, arg 'y': ${y}
	<%block name="foo" />
</base>

## inheriting.mako
<%inherit file="base.mako" />
<%block name="foo">
	<title>${x}</title>
	<desc>${y}</desc>
</%block>

And two cases (first works, but second don't):

mylookup.get_template('inheriting.mako').render(x='title', y='description'))
mylookup.get_template('inheriting.mako').render())

Though args with default values are set in <%page> and are valid/visible in the inheritted template (base.mako; note inheriting (inheriting.mako<-base.mako) involved) , but not in the inheriting template and it's named blocks.
I know that i could pass args to named blocks via args param explicitly, but shouldn't <%page args (default values) also be inherited? (render() supplied args are visible in all templates/contexts)
In other wors: is there any posibility to set all arg default values in one place?

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 two cases with base.mako and inheriting.mako through mylookup.get_template('inheriting.mako').render(), comparing supplied arguments with the defaults declared in the <%page> directive. Trace how arguments reach the inherited template and its named block; done means the intended default-value behavior is established and covered by an appropriate regression test or documented as unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.