[Zope3-checkins] CVS: Zope3/src/zope/app/xml - configure.zcml:1.1 schemainterface.py:1.1 metaconfigure.py:1.2

Philipp von Weitershausen philikon@philikon.de
Thu, 10 Apr 2003 12:08:16 -0400


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

Modified Files:
	metaconfigure.py 
Added Files:
	configure.zcml schemainterface.py 
Log Message:
Implemented a new type of interface for XML schema interfaces. Its class is
XMLSchemaInterfaceClass.


=== Added File Zope3/src/zope/app/xml/configure.zcml ===
<zopeConfigure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:browser="http://namespaces.zope.org/browser">

<!-- we need to allow methods of XMLSchemaInterfaceClass so we can access them
     through the security proxy -->
<content class=".schemainterface.XMLSchemaInterfaceClass">
  <allow interface="zope.interface.interfaces.IInterface"
         attributes="__bases__" />
</content>

</zopeConfigure>


=== Added File Zope3/src/zope/app/xml/schemainterface.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""XML schema interfaces

$Id: schemainterface.py,v 1.1 2003/04/10 16:07:45 philikon Exp $
"""

from zope.interface.interface import InterfaceClass
from zope.app.interfaces.xml.representable import IXMLRepresentable

class XMLSchemaInterfaceClass(InterfaceClass):
    """
    Class for XML schema interfaces
    """

    __safe_for_unpickling__ = True
    
    def __init__(self, uri):
        doc = """XML Schema based interface

    Instances of this interface must be XML representable with XML that conforms
    to the schema: %s""" % uri
        super(XMLSchemaInterfaceClass, self).__init__(uri, (IXMLRepresentable,),
                                                      __doc__=doc)

    def __reduce__(self):
        return (XMLSchemaInterfaceClass, (self.getName(),))

    #
    # Identity comparison does not work with security proxies. Therefore we
    # override the default equality comparison (which does identity comparison).
    #

    def __eq__(self, other):
        return (self.__class__ == other.__class__ and
                self.__name__ == other.__name__)

    def __hash__(self):
        return hash(self.__name__)


=== Zope3/src/zope/app/xml/metaconfigure.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/xml/metaconfigure.py:1.1	Wed Apr  9 16:51:33 2003
+++ Zope3/src/zope/app/xml/metaconfigure.py	Thu Apr 10 12:07:45 2003
@@ -16,17 +16,11 @@
 $Id$
 """
 
-from zope.interface.interface import InterfaceClass
-from zope.app.interfaces.xml.representable import IXMLRepresentable
+from zope.app.xml.schemainterface import XMLSchemaInterfaceClass
 from zope.app.component.globalinterfaceservice import interfaceService
 
 def schemaInterface(_context, uri):
-    doc = """XML Schema based interface
-
-    Instances of this interface must be XML representable with XML that conforms
-    to the schema: %s""" % uri
-    schema_interface = InterfaceClass(uri, (IXMLRepresentable,),
-                                      {'__doc__': doc})
+    schema_interface = XMLSchemaInterfaceClass(uri)
     # XXX normally we would return an Action here, but then the interface would
     # not be resolvable if other configuration directives make references to it
     interfaceService.provideInterface(uri, schema_interface)