Edgewall Software

Ticket #254 (closed defect: fixed)

Opened 3 years ago

Last modified 3 months ago

Genshi since 0.5.1 produces duplicated items in py:match

Reported by: felix.schwarz@… Owned by: cmlenz
Priority: critical Milestone: 0.6
Component: Template processing Version: 0.5.1
Keywords: Cc:

Description

Since the update to Genshi 0.5.1 the content from most of our py:match directives appears twice in the output. This happens on all platforms (Linux, Windows). I verified that this is still a problem in the current 0.5 stable branch (r908).

Attachments

test_duplicated_item.py Download (1.1 KB) - added by felix.schwarz@… 3 years ago.
This is a test case for the described problem (can reproduce it with the current 0.6 trunk, too)
test_no_match_with_single_slash.py Download (1.3 KB) - added by felix.schwarz@… 3 years ago.
Actually, I found another problem in our code which was caused by the mentioned commits. However, for this second problem there is a workaround by using //h1 as match expression (see the second testcase)
duplicated_item.JPG Download (11.0 KB) - added by didley@… 3 years ago.
Screenshot
genshi-254.patch Download (2.0 KB) - added by Felix Schwarz <felix.schwarz@…> 2 years ago.
finally a patch for the dreaded issue

Change History

Changed 3 years ago by felix.schwarz@…

This is a test case for the described problem (can reproduce it with the current 0.6 trunk, too)

  Changed 3 years ago by felix.schwarz@…

The change of behavior was introduced in r884, r885.

Changed 3 years ago by felix.schwarz@…

Actually, I found another problem in our code which was caused by the mentioned commits. However, for this second problem there is a workaround by using //h1 as match expression (see the second testcase)

  Changed 3 years ago by felix.schwarz@…

Ok, I found a workaround for us now: The duplication test case does pass if the first py:match (which is essentially '<div py:match="div">') is modified to use '<div py:match="body//div">'.

So it's essentially the same workaround as for the "no match" test case.

  Changed 3 years ago by felix.schwarz@…

Sometimes I had to resort to something like '*/div'. For now this is okay with us but it seems to be very fragile so we are eager to see a real fix for this.

  Changed 3 years ago by cmlenz

  • status changed from new to assigned

I'm too tired for grokking the details of what's going on here, but here two simple options for fixing the first example you posted:

  • The once="true" attribute can only be used when py:match is used as an element. In your example, it's simply ignored and passed on through into the output. If you make that match template a <py:match> example, the duplication goes away.
  • Moving the first match template after the other two match templates also gets rid of the duplication.

  Changed 3 years ago by felix.schwarz@…

Thanks for looking at this. Unfortunately, we can't change the order of the py:match directives as we're re-using some trac templates and all these py:matches originate from trac. Only the last one with the wrong 'py:match' is ours.

  Changed 3 years ago by didley@…

I'm using 0.5.2dev and I got this in my admin panel

Screenshot

Could be it's the same reason.

didley

Changed 3 years ago by didley@…

Screenshot

follow-up: ↓ 8   Changed 3 years ago by stromnov@…

Is it fixed in 0.6dev branch?

in reply to: ↑ 7   Changed 3 years ago by Felix Schwarz <felix.schwarz@…>

No, both tests still fail for trunk (as of r1059).

  Changed 3 years ago by osimons

Isn't this the same as #293?

  Changed 3 years ago by Felix Schwarz <felix.schwarz@…>

I don't think so because I checked some weeks ago with the current trunk at that time but the bug was still there.

  Changed 2 years ago by Felix Schwarz <felix.schwarz@…>

Just as a note for further investigation: This bug might be present in 0.5.1 already. We had a  customer report that indicated adding a site.html in trac (hence a fourth py:match) exposed the same behavior.

  Changed 2 years ago by anonymous

  • status changed from assigned to closed
  • resolution set to fixed

  Changed 2 years ago by anonymous

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 2 years ago by Felix Schwarz <felix.schwarz@…>

finally a patch for the dreaded issue

  Changed 2 years ago by cboos

Great! I don't pretend to understand the fix, but it seems to work.

However import re is missing, for the test:

  • genshi/template/tests/directives.py

    diff --git a/genshi/template/tests/directives.py b/genshi/template/tests/directives.py
    a b  
    1212# history and logs, available at http://genshi.edgewall.org/log/. 
    1313 
    1414import doctest 
     15import re 
    1516import sys 
    1617import unittest 

Otherwise all tests pass on Windows, if that helps. I'll keep the change in my test environment for Trac to check if there are no adverse effects.

  Changed 2 years ago by cmlenz

  • status changed from reopened to closed
  • resolution set to fixed
  • milestone changed from 0.5.2 to 0.6

Patch applied in r1093. Thanks you so much!

  Changed 2 years ago by Felix Schwarz <felix.schwarz@…>

Thanks for applying the patch :-)

You won't release another 0.5.x, right? Otherwise I would like to see the patch also for this branch - if the regression will make it in a stable release, we'll have a lot of support troubles.

  Changed 21 months ago by anonymous

i tried to change the condition in setup.py file from 0.6 ---> 0.5 and it works fine

Add/Change #254 (Genshi since 0.5.1 produces duplicated items in py:match)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.