sqlalchemy / sqlalchemy/mako

proposal - standardizing directories and template paths

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

Nobody has claimed this yet.

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

Description

Migrated issue, originally created by jvanasco (@jvanasco)

I've been working on some tools to precompile templates before a webserver forks, and have run into a few issues when trying to build this out more reliably.

  1. 'directories' can be duplicates. I'm not sure this will affect anything down the line, but it might make sense. this is relatively simple to fix.

    lookup = TemplateLookup(directories=['templates', 'templates/', 'templates'])
    print lookup.directories
    ['templates', 'templates', 'templates']

  2. filenames aren't standardized, so the same template can become 2 objects/compiled 2 ways (relative vs absolute). this will require more thought.

    lookup = TemplateLookup(directories=['templates'])
    t1 = lookup.get_template('goodnight_moon.mako')
    t2 = lookup.get_template('/goodnight_moon.mako')
    print lookup._collection
    {'goodnight_moon.mako': <mako.template.Template object at 0x1015df510>, '/goodnight_moon.mako': <mako.template.Template object at 0x1015df850>}

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 with the TemplateLookup directory handling and the get_template path lookup described in the examples, then inspect how lookup.directories and _collection are populated. Define the expected canonical form for duplicate directories and relative versus absolute template names; done means equivalent inputs no longer create duplicate compiled template objects.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.