Beispiel #1
0
    def DOMDeserialize(self,
                       rootElement,
                       parentPref,
                       prefFactory,
                       basedir=None,
                       chainNotifications=0):
        xpPref = components.classes["@activestate.com/koPreferenceCache;1"] \
                  .createInstance(components.interfaces.koIPreferenceCache)
        newPref = UnwrapObject(xpPref)
        newPref.id = rootElement.getAttribute('id') or ""
        newPref.idref = rootElement.getAttribute('idref') or ""
        newPref.basedir = basedir
        try:
            max_length = int(rootElement.getAttribute('max_length'))
            newPref._maxsize = max_length
        except ValueError:
            log.error("The 'max_length' attribute is invalid")

        # Iterate over the elements of the preference set,
        # deserializing them and fleshing out the new preference
        # set with content.
        childNodes = rootElement.childNodes

        # Keep the new prefs in a list, then add them in reverse.  This
        # will magically put everything in the correct order.
        sub_prefs = []
        for node in childNodes:
            if node and node.nodeType == minidom.Node.ELEMENT_NODE:
                pref = _dispatch_deserializer(self, node, newPref, prefFactory,
                                              basedir, chainNotifications)
                if pref:
                    if pref.id:
                        sub_prefs.append(pref)
                    else:
                        log.error("Preference has no id - dumping preference:")
                        pref.dump(0)

        sub_prefs.reverse()
        for pref in sub_prefs:
            newPref.setPref(pref)

        return xpPref
Beispiel #2
0
    def DOMDeserialize(self, rootElement, parentPref, prefFactory, basedir=None, chainNotifications=0):
        xpPref = components.classes["@activestate.com/koPreferenceCache;1"].createInstance(
            components.interfaces.koIPreferenceCache
        )
        newPref = UnwrapObject(xpPref)
        newPref.id = rootElement.getAttribute("id") or ""
        newPref.idref = rootElement.getAttribute("idref") or ""
        newPref.basedir = basedir
        try:
            max_length = int(rootElement.getAttribute("max_length"))
            newPref._maxsize = max_length
        except ValueError:
            log.error("The 'max_length' attribute is invalid")

        # Iterate over the elements of the preference set,
        # deserializing them and fleshing out the new preference
        # set with content.
        childNodes = rootElement.childNodes

        # Keep the new prefs in a list, then add them in reverse.  This
        # will magically put everything in the correct order.
        sub_prefs = []
        for node in childNodes:
            if node and node.nodeType == minidom.Node.ELEMENT_NODE:
                pref = _dispatch_deserializer(self, node, newPref, prefFactory, basedir, chainNotifications)
                if pref:
                    if pref.id:
                        sub_prefs.append(pref)
                    else:
                        log.error("Preference has no id - dumping preference:")
                        pref.dump(0)

        sub_prefs.reverse()
        for pref in sub_prefs:
            newPref.setPref(pref)

        return xpPref