End state is not being processed properly

Bug #444424 reported by Zeth on 2009-10-06
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pixelise
High
Andrew West

Bug Description

The end element is not being caught correctly. E.g. when you start at an element that is a child of another element and keep processing, the parent's end tag is not being caught.

I am using the demo site (in the tarball), and using this function:

def testendofelement():
    """See if Pixelise works with hanging elements."""
    from pixelise.core import Collection
    collection = Collection()
    paras = collection.query('//publicationStmt/p')
    para = paras.next()
    pixelate = 'testend.py'
    collection.process_element(para, pixelate, 'True')

And this pixelate template:

PIXELISE_PATTERNS = {
    'p': 'para',
    'publicationStmt': 'publication_stmt',
    'sourceDesc': 'source_desc',
}

def para(element, state, context):
    """A paragraph"""
    if state == 'end':
        return '</p>'

def publication_stmt(element, state, context):
    """A paragraph"""
    if state == 'end':
        raise RuntimeError

def source_desc(element, state, context):
    """An element too far"""
    return {'stop_processing': True}

Zeth (zeth0) on 2009-10-06
Changed in pixelise:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Zeth (zeth0)
Andrew West (andrewwest) on 2009-10-06
Changed in pixelise:
assignee: Zeth (zeth0) → Andrew West (andrewwest)
Zeth (zeth0) wrote :

Problem is worse:

A load of elements get processed that are not part of it, e.g.:

def country(element, state, context):
    """This should not be being found at all."""
    print "How come we get here?"

Zeth (zeth0) wrote :

Okay ignore last comment, as the scriptures say: "well when it's doing sourceDesc it will process everything inside the sourceDesc"

Zeth (zeth0) wrote :

there is a flaw in the logic with regards to how it handles transversing back up the tree at the end of an element

Zeth (zeth0) wrote :

... "It should transverse back up, looking for the next sibling it can descend down into or until it hits the top element"

Andrew West (andrewwest) wrote :

Fix committed.

Looks like it was as mentioned in above comment, _process_element did transverse up the element tree when moving past the end of an element, but didn't process those element using a pixelate.

I've put a small test case into tests.py to test for this behaviour, and checked against the existing tests, looks good but should be tested against the newer tests to confirm it doesn't break existing behaviour.

Changed in pixelise:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers