Catching Exception during Silva export

Bug #101753 reported by Benno Luthiger
10
Affects Status Importance Assigned to Milestone
Silva
Fix Released
Low
Eric Casteleijn

Bug Description

On our sites when trying a 'Silva Full-Media Export', we frequently experience a
failure (caused by an AttributeError). After analyzing the situation, I found
out that the problem was caused by changes in our custom metadata sets we
applied in the past.
Say we have two metadata sets 'my_container_set' and 'my_author_set'. During the
first period, the element 'force_https' was part of set 'my_container_set'.
After a while, however, we found out that this element needs to be member of the
set 'my_author_set'. Applying this change doesn't lead to any problems in the
productive site, i.e. the pages are displayed as expected.
However, such a change can lead to problems if such a site is exported using
'Silva Full-Media Export'. During the first period, objects are created and
stored to the ZODB making references to the metadata element 'force_https' in
the set 'my_container_set'. In the subsequent period ('force_https' member of
'my_author_set') when preparing the Silva export, a metadata item is retrieved
with the key 'force_https'. Then, the system tries to look up the metadata
field, calling Binding.getElement('my_container_set', 'force_https'). This
inevitably results in an AttributeError.

Therefore, my suggestion is to make this export more stable by catching the
AttributeError in Silva.silvaxml.xmlexport.metadata() (line 72ff) as follows:
---
            for key, value in items:
                try:
                    field = binding.getElement(set_id, key).field
                except AttributeError:
                    continue
                self.startElementNS(namespace, key)
                field.validator.serializeValue(field, value, self)
                self.endElementNS(namespace, key)
---

Revision history for this message
Eric Casteleijn (thisfred) wrote :

I'm sort of hesitant to introduce this sort of defensive coding, since it may
end up cloaking other more serious bugs. I'll have a look to see why the key is
looked up in the wrong metadata set in the first place.

If I understand correctly, the element was moved from set1 to set2, but on
export it is still looked up on set1, right?

Revision history for this message
Flynt (flyntle) wrote :

We (Benno and I) agree with eric's objection. So we can close this issue.

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.