macro pagetemplates are not automatically reloaded when changed

Bug #162261 reported by Martijn Faassen
6
Affects Status Importance Assigned to Milestone
grok
Fix Released
High
Martijn Faassen
1.0
Fix Released
High
Martijn Faassen

Bug Description

If a page template is a macro and you change the macro, the changed macro is not automatically reloaded. I think it did work before, but it fails in
Grok 0.11.

Changed in grok:
assignee: nobody → regebro-gmail
importance: Undecided → High
milestone: none → 0.11
status: New → Confirmed
todd (todd-infrae)
Changed in grok:
milestone: 0.11 → 1.0
Changed in grok:
assignee: regebro-gmail → faassen
Revision history for this message
Reinout van Rees (reinout) wrote :

Found the problem: grokcore/view/components.py, around line 213. In the PageTemplate class::

    def _initFactory(self, factory):
        factory.macros = self._template.macros

That ought to be something like::

    def _initFactory(self, factory):
        """For zope page templates only: add macros property to view class.
        """
        def _get_macros(self):
            return self.template._template.macros
        factory.macros = property(_get_macros)

Reason: self_template.macros is a property in zope pagetemplate that does a _cook_check() and returns self._v_macros. With the existing code, the macros property of zope pagetemplate is called just once and subsequent cook checks don't happen.

With the new code, the original macros() call, including cook check, is happening all the time.

The special macros attribute setting by _initFactory is, according to jwkolman, especially for zope page templates. So this changes seems warranted.

I'll mail this to the grok list, too. And I'll prepare a patch with test.

Revision history for this message
Reinout van Rees (reinout) wrote :

Fixed (including test) in r99003.

Revision history for this message
Reinout van Rees (reinout) wrote :

Fix committed in r99003

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.