|
From: <bov...@us...> - 2007-07-10 20:25:41
|
Revision: 1405
http://svn.sourceforge.net/pywebsvcs/?rev=1405&view=rev
Author: boverhof
Date: 2007-07-10 13:25:44 -0700 (Tue, 10 Jul 2007)
Log Message:
-----------
M XMLSchema.py
-- If one tries to grab a schema item using the helper methods, if that item doesn't exist and the namespace is not in the BUILT_IN_NAMESPACES list then throw a SchemaError. Now failure to specify an import dependency will result in an error like:
ZSI.wstools.XMLSchema.SchemaError: schema "urn:webservices" does not import namespace "urn:base"
when "item.getTypeDefinition()" is called and the "type" attribute value QName is in a namespace that hasn't been declared as a dependency
So basically this throws errors when can't find a schema item that is supposed to be defined, rather than just returning None most of the time, which is always an error condition.
M a Utility.py
-- use M2Crypto if available for TimeOutSocket, and standard "ssl" if it's not
--
Modified Paths:
--------------
trunk/wstools/Utility.py
trunk/wstools/XMLSchema.py
Modified: trunk/wstools/Utility.py
===================================================================
--- trunk/wstools/Utility.py 2007-07-07 00:46:05 UTC (rev 1404)
+++ trunk/wstools/Utility.py 2007-07-10 20:25:44 UTC (rev 1405)
@@ -159,14 +159,19 @@
# If ssl is not compiled into Python, you will not get an exception
# until a conn.endheaders() call. We need to know sooner, so use
# getattr.
- if hasattr(socket, 'ssl'):
+ try:
+ import M2Crypto
+ except ImportError:
+ if not hasattr(socket, 'ssl'):
+ raise RuntimeError, 'no built-in SSL Support'
+
conn = TimeoutHTTPS(host, None, timeout)
else:
- import M2Crypto
ctx = M2Crypto.SSL.Context()
ctx.set_session_timeout(timeout)
conn = M2Crypto.httpslib.HTTPSConnection(host, ssl_context=ctx)
- #conn.set_debuglevel(1)
+ conn.set_debuglevel(1)
+
else:
conn = TimeoutHTTP(host, None, timeout)
Modified: trunk/wstools/XMLSchema.py
===================================================================
--- trunk/wstools/XMLSchema.py 2007-07-07 00:46:05 UTC (rev 1404)
+++ trunk/wstools/XMLSchema.py 2007-07-10 20:25:44 UTC (rev 1405)
@@ -15,7 +15,7 @@
ident = "$Id$"
import types, weakref, sys, warnings
-from Namespaces import SCHEMA, XMLNS
+from Namespaces import SCHEMA, XMLNS, SOAP
from Utility import DOM, DOMException, Collection, SplitQName, basejoin
from StringIO import StringIO
@@ -37,8 +37,8 @@
ATTRIBUTES = 'attr_decl'
ELEMENTS = 'elements'
MODEL_GROUPS = 'model_groups'
+BUILT_IN_NAMESPACES = [SOAP.ENC,] + SCHEMA.XSD_LIST
-
def GetSchema(component):
"""convience function for finding the parent XMLSchema instance.
"""
@@ -574,16 +574,22 @@
attribute -- an information item attribute, with a QName value.
collection -- collection in parent Schema instance to search.
"""
- obj = None
tdc = self.getAttributeQName(attribute)
- if tdc:
- obj = self.getSchemaItem(collection, tdc.getTargetNamespace(), tdc.getName())
+ if not tdc:
+ return
- return obj
+ obj = self.getSchemaItem(collection, tdc.getTargetNamespace(), tdc.getName())
+ if obj:
+ return obj
+# raise SchemaError, 'No schema item "%s" in collection %s' %(tdc, collection)
+ return
+
def getSchemaItem(self, collection, namespace, name):
"""returns object instance representing namespace, name,
- or if does not exist return None.
+ or if does not exist return None if built-in, else
+ raise SchemaError.
+
namespace -- namespace item defined in.
name -- name of item.
collection -- collection in parent Schema instance to search.
@@ -599,8 +605,14 @@
return obj
if not parent.imports.has_key(namespace):
- return None
-
+ if namespace in BUILT_IN_NAMESPACES:
+ # built-in just return
+ # WARNING: expecting import if "redefine" or add to built-in namespace.
+ return
+
+ raise SchemaError, 'schema "%s" does not import namespace "%s"' %(
+ parent.targetNamespace, namespace)
+
# Lazy Eval
schema = parent.imports[namespace]
if not isinstance(schema, XMLSchema):
@@ -609,6 +621,10 @@
parent.imports[namespace] = schema
if schema is None:
+ if namespace in BUILT_IN_NAMESPACES:
+ # built-in just return
+ return
+
raise SchemaError, 'no schema instance for imported namespace (%s).'\
%(namespace)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|