Merge lp:~wallyworld/zope.pagetemplate/fix-isinstance into lp:zope.pagetemplate
Proposed by
Ian Booth
Status: | Needs review |
---|---|
Proposed branch: | lp:~wallyworld/zope.pagetemplate/fix-isinstance |
Merge into: | lp:zope.pagetemplate |
Diff against target: |
91 lines (+45/-4) 2 files modified
src/zope/pagetemplate/engine.py (+4/-4) src/zope/pagetemplate/tests/test_engine.py (+41/-0) |
To merge this branch: | bzr merge lp:~wallyworld/zope.pagetemplate/fix-isinstance |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tres Seaver | Approve | ||
Review via email: mp+38499@code.launchpad.net |
Description of the change
I have made a small improvement to the short circuit in the traversal logic if the object subclasses dict.
The code in engine.py used to say:
if getattr(object, '__class__', None) == dict:
It has been changed to:
if isinstance(object, dict):
The reason for the change is that I have made some optimisations to Launchpad menu rendering and now there's instances of MenuLinksDict(dict) classes instead of vanilla dicts. These new instances extend dict and so the original check in engine.py failed. My change arguably is the better way to do the check and it makes the short circuit work again for Launchpad menus :-)
To post a comment you must log in.
Overall, the patch looks fine, but it needs a test showing that the
subclassing bit (the part you care about) works.