Changeset 5216 for ndgCommon


Ignore:
Timestamp:
21/04/09 17:20:15 (11 years ago)
Author:
cbyrom
Message:

Tighten up use of xhtml in atom:content element - NB, this requires a
fix when data is re-ingested via elementtree, as this doesn't respect
inner namespaces properly. Also add new keyword to TextArea? template
function, to allow the content to be displayed 'as is' - i.e. without
the XML escaping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/models/Atom.py

    r5215 r5216  
    654654        else: 
    655655            content.attrib["type"] = "xhtml" 
    656             div = ET.SubElement(content, 'div') 
     656            div = ET.SubElement(content, 'xhtml:div') 
    657657            div.attrib["xmlns:xhtml"] = ndgObject.XHTML_NS 
     658             
    658659            div.text = self.Content 
    659660         
     
    772773            else: 
    773774                logging.debug("No file data - adding contents of element instead") 
    774                 divEl = contentTag.find('{%s}div'%ndgObject.ATOM_NS)#XHTML_NS) 
     775                divEl = contentTag.find('{%s}div'%ndgObject.XHTML_NS) 
     776                 
    775777                div = divEl.text 
    776778                 
     
    778780                for child in divEl.getchildren(): 
    779781                    div += ET.tostring(child) 
    780                      
     782 
     783                # NB, Elementtree tends to revert the namespace of the xhtml 
     784                # elements to the parent Atom NS - so switch this back 
     785                div = div.replace(ndgObject.ATOM_NS, ndgObject.XHTML_NS) 
    781786                self.Content = div 
    782787         
Note: See TracChangeset for help on using the changeset viewer.