source: products/quintagroup.transmogrifier/branches/dictionary/quintagroup/transmogrifier/namespaces/__init__.py @ 2720

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

merge plone2.1 branche updates (r2426-2428,2433-2452): manifests with valid xml now, binary files fully dumped, local roles are imported, control characters are handled properly

File size: 713 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
8from cmfns import CMF
9
10
11def replaceNamespace(ns):
12    """Replace namespaces by prefix"""
13    if not isinstance(ns, XmlNamespace):
14        ns = ns()
15
16    nses = ATXMLMarshaller.namespaces
17    prefixes = [nses.index(n) for n in nses if n.prefix == ns.prefix]
18    if len(prefixes) == 0:
19        return False
20
21    idx = prefixes[0]
22    nses.pop(idx)
23    nses.insert(idx, ns)
24
25replaceNamespace(DublinCore)
26replaceNamespace(Archetypes)
27replaceNamespace(CMF)
Note: See TracBrowser for help on using the repository browser.