Skip to content

Commit

Permalink
Drop use of python:exists() in template
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Apr 24, 2015
1 parent 788ff0f commit 1e415bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
2.2.13 (unreleased)
-------------------

- Drop use of python:exists() in templates.
[pbauer]

- Replace deprecated JavaScript functions with their jQuery equivalents.
[thet]

Expand Down
15 changes: 11 additions & 4 deletions Products/CMFEditions/browser/diff.pt
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,22 @@
This field has no inline difference view.
</p>

<div class="fieldDiff code-diff" style="display: none">
<pre tal:condition="exists:diff/html_diff" tal:content="structure python:diff.html_diff(wrapcolumn=80)">
<div class="fieldDiff code-diff"
style="display: none"
tal:define="has_html_diff diff/html_diff | nothing;
has_ndiff diff/ndiff | nothing">
<pre tal:condition="exists:diff/html_diff"

This comment has been minimized.

Copy link
@ichim-david

ichim-david Apr 25, 2015

Member

Hey @pbauer,
I think you missed this exists call.

This comment has been minimized.

Copy link
@pbauer

pbauer Apr 26, 2015

Author Member

@ichim-david this is different. This is the tal-statement "exists: some/tal" whereas the other is "python: exists('some-tal-statement')". I found the latter sometimes causes errors for yet undetermined reasons. Also I think it is hard to read and not pythonic. Who but a hardcore-plone-dev would understand that it passes a string to a python-method but actually 'exists' is not a really python method but only exists when parsing tal and the string is actually a tal-path. Ugrh!

This comment has been minimized.

Copy link
@mauritsvanrees

mauritsvanrees Aug 12, 2015

Member

Since this change, ndiff can be called when it is not needed. And because of a problem in ndiff in CMFDiffTool, this can lead to a UnicodeDecodeError. See the discussion in plone/Products.CMFPlone#820

I have restructured this some more in 3fcb68e. Seems fine now.

tal:content="structure python:diff.html_diff(wrapcolumn=80)">
HTML formatted differences
</pre>

<pre class="fieldDiff code-diff" tal:condition="python:not exists('diff/html_diff') and exists('diff/ndiff')" tal:content="diff/ndiff">
<pre class="fieldDiff code-diff"
tal:condition="python:not has_html_diff and has_ndiff"
tal:content="diff/ndiff">
ndiff formatted differences
</pre>
<p class="fieldDiff" tal:condition="python:not exists('diff/html_diff') and not exists('diff/ndiff')">
<p class="fieldDiff"
tal:condition="python:not has_html_diff and not has_ndiff">
This field has no code difference view.
</p>
</div>
Expand Down

0 comments on commit 1e415bc

Please sign in to comment.