source: products/quintagroup.transmogrifier/branches/plone-2.1/quintagroup.transmogrifier/quintagroup/transmogrifier/namespaces/__init__.py @ 1393

Last change on this file since 1393 was 1393, checked in by piv, 14 years ago

override Marshall namespaces to handle Control Characters properly

File size: 669 bytes
Line 
1# import Products.Marshall namespaces to ensure it's registered
2# before we override it
3from Products.Marshall import namespaces
4from Products.Marshall.handlers.atxml import ATXMLMarshaller, XmlNamespace
5
6from atns import Archetypes
7from dcns import DublinCore
8
9
10def replaceNamespace(ns):
11    """Replace namespaces by prefix"""
12    if not isinstance(ns, XmlNamespace):
13        ns = ns()
14
15    nses = ATXMLMarshaller.namespaces
16    prefixes = [nses.index(n) for n in nses if n.prefix == ns.prefix]
17    if len(prefixes) == 0:
18        return False
19
20    idx = prefixes[0]
21    nses.pop(idx)
22    nses.insert(idx, ns)
23
24replaceNamespace(DublinCore)
25replaceNamespace(Archetypes)
Note: See TracBrowser for help on using the repository browser.