[Zope3-checkins] CVS: Zope3/src/zope/app/content - xmldocument.py:1.3

Philipp von Weitershausen philikon@philikon.de
Fri, 11 Apr 2003 10:44:58 -0400


Update of /cvs-repository/Zope3/src/zope/app/content
In directory cvs.zope.org:/tmp/cvs-serv8513/content

Modified Files:
	xmldocument.py 
Log Message:
Refactored dynamic interface settings based on XML schemas so it can be
used in other code.


=== Zope3/src/zope/app/content/xmldocument.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/content/xmldocument.py:1.2	Thu Apr 10 09:04:43 2003
+++ Zope3/src/zope/app/content/xmldocument.py	Fri Apr 11 10:44:27 2003
@@ -15,10 +15,9 @@
 $Id$
 """
 from persistence import Persistent
-from zope.app.interfaces.annotation import IAttributeAnnotatable
 from zope.app.interfaces.content.xmldocument import IXMLDocument
-from zope.app.xml.w3cschemalocations import getW3CXMLSchemaLocations
-from zope.app.component.globalinterfaceservice import interfaceService
+from zope.app.xml.w3cschemalocations import\
+     setInstanceInterfacesForXMLText
 
 class XMLDocument(Persistent):
 
@@ -37,49 +36,9 @@
         # XML Schema interfaces are looked up for each mentioned schema,
         # and if this interface exists, we manipulate this instance to
         # state it has those interfaces.
-        
-        # XXX the interface manipulation is a hack, should be fixed after
-        # interfacegheddon
-        
-        schema_uris = getW3CXMLSchemaLocations(value)
-
-        # if there are no schemas, then we go back to whatever the class
-        # implements
-        if not schema_uris:
-            try:
-                del self.__implements__
-            except AttributeError:
-                pass
-            return
-
-        cls = self.__class__
-        if isinstance(cls.__implements__, tuple):
-            implements = list(cls.__implements__)
-        else:
-            implements = [cls.__implements__]
-
-        orig_implements = implements[:]
-        
-        for schema_uri in schema_uris:
-            interface = interfaceService.queryInterface(schema_uri, None)
-            if interface is not None and interface not in implements:
-                implements.append(interface)
-
-        # if there are no changes in the interfaces, go back to whatever
-        # the class implements
-        if implements == orig_implements:
-            try:
-                del self.__implements__
-            except AttributeError:
-                pass
-            return
-
-        self.__implements__ = tuple(implements)    
+        setInstanceInterfacesForXMLText(self)
 
     def _getSource(self):
         return self._source
     
     source = property(_getSource, _setSource)
-
-    
-