Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2511 (closed defect: migrated)

Opened 9 years ago

Last modified 8 years ago

Helpers are broken when using Jinja2

Reported by: seedifferently Owned by:
Priority: normal Milestone: 2.1
Component: TurboGears Version: 2.1
Severity: major Keywords:
Cc: silentsound+tg@…

Description

I have not tested this with other template files, but with Jinja2 you will receive the following error when trying to use a webhelper imported from your proj/lib/helpers.py file:

'tg.util.Bunch object' has no attribute 'myhelper'

It works fine in the TG 2.1 beta, but returns that error in rc1.

Thanks, Seth

Change History

comment:1 Changed 9 years ago by chrisz

  • Milestone changed from __unclassified__ to 2.1

Can you check if this is fixed with  changeset 2e37c77e2194?

comment:2 Changed 9 years ago by silentsound

I'm getting a similar error when using them from Mako as h with the fixes from the above changeset. However, helpers works fine. I've pinpointed the issue to line 36 in the my_pylons_globals monkey patch in render.py:

    h = conf.package.lib.helpers

At that point, conf is a dictionary, so that lookup always fails. The fix is to use the config import:

    h = config.package.lib.helpers

Or, alternatively, use a standard dictionary lookup:

    h = conf['package'].lib.helpers

comment:3 Changed 9 years ago by silentsound

  • Cc silentsound+tg@… added

comment:4 Changed 9 years ago by seedifferently

  • Version changed from 2.1rc1 to 2.1

@chrisz: Still getting the same error in the final 2.1 release.

comment:5 Changed 8 years ago by pedersen

  • Status changed from new to closed
  • Resolution set to migrated
Note: See TracTickets for help on using tickets.