Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
/ pyxb Public archive
forked from pabigot/pyxb

Commit

Permalink
structures: remove mis-use of derivation method as indicating resolution
Browse files Browse the repository at this point in the history
Interpreting completed resolution as having a set __derivationMethod
required that we instead store and reference __pendingDerivationMethod,
even though in fact the derivation method is fixed and was not the
characteristic that was pending.  This causes issues when it becomes
necessary to access the derivation method to control validation during
resolution.

Replace with a flag that explicitly notes resolution is complete, and
let derivation method be own true self.
  • Loading branch information
pabigot committed May 20, 2017
1 parent 73ff233 commit b20fe61
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions pyxb/xmlschema/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ def _updateFromOther_csc (self, other):

if not other.isResolved():
if pyxb.namespace.BuiltInObjectUID != self._objectOrigin().generationUID():
self.__derivationMethod = None
self.__isResolved = False

return self

Expand Down Expand Up @@ -2015,7 +2015,7 @@ def UrTypeDefinition (cls, schema=None, in_builtin_definition=False):
bi.setNameInBinding(bi.name())

# The ur-type is always resolved
bi.__derivationMethod = cls.DM_restriction
bi.__isResolved = True

cls.__UrTypeDefinition = bi
return cls.__UrTypeDefinition
Expand Down Expand Up @@ -2210,10 +2210,8 @@ def __completeProcessing (self, method, content_style):
del self.__attributeGroups
self.__ckw = None

# Only now that we've succeeded do we store the method, which
# marks this component resolved.

self.__derivationMethod = method
# Mark the type resolved
self.__isResolved = True
return self

def __simpleContent (self, method, **kw):
Expand Down Expand Up @@ -2252,7 +2250,6 @@ def __simpleContent (self, method, **kw):
__PrivateTransient.update(['ctscRestrictionNode' ])
__effectiveMixed = None
__effectiveContent = None
__pendingDerivationMethod = None
__isComplexContent = None
def _isComplexContent (self):
return self.__isComplexContent
Expand Down Expand Up @@ -2371,6 +2368,7 @@ def __complexContent (self, method):
assert (self.CT_EMPTY == content_type) or ((type(content_type) == tuple) and (content_type[1] is not None))
return content_type

__isResolved = False
def isResolved (self):
"""Indicate whether this complex type is fully defined.
Expand All @@ -2388,13 +2386,13 @@ def isResolved (self):
latter in the list of type definitions to be resolved. See
Schema._addNamedComponent.
"""
# Only unresolved nodes have an unset derivationMethod
return (self.__derivationMethod is not None)
return self.__isResolved

# Back door to allow the ur-type to re-resolve itself. Only needed when
# we're generating bindings for XMLSchema itself.
def _setDerivationMethod (self, derivation_method):
self.__derivationMethod = derivation_method
self.__isResolved = True
return self

def __setContentFromDOM (self, node, **kw):
Expand Down Expand Up @@ -2459,8 +2457,7 @@ def __setContentFromDOM (self, node, **kw):
self.__baseTypeDefinition = None
# The content is defined by the restriction/extension element
definition_node_list = ions.childNodes
# deriviationMethod is assigned after resolution completes
self.__pendingDerivationMethod = method
self.__derivationMethod = method
self.__isComplexContent = is_complex_content
self.__ctscRestrictionNode = ctsc_restriction_node
self.__ctscClause2STD = clause2_std
Expand All @@ -2474,7 +2471,7 @@ def __setContentFromDOM (self, node, **kw):
self.__anyAttribute = any_attribute

if self.__isComplexContent:
self.__setComplexContentFromDOM(node, content_node, definition_node_list, self.__pendingDerivationMethod, **kw)
self.__setComplexContentFromDOM(node, content_node, definition_node_list, self.__derivationMethod, **kw)

# Creation does not attempt to do resolution. Queue up the newly created
# whatsis so we can resolve it after everything's been read in.
Expand Down Expand Up @@ -2523,11 +2520,11 @@ def _resolve (self):
# depends on the base type which we know is good.
if self.__contentType is None:
if self.__isComplexContent:
content_type = self.__complexContent(self.__pendingDerivationMethod)
content_type = self.__complexContent(self.__derivationMethod)
self.__contentStyle = 'complex'
else:
# The definition node list is not relevant to simple content
content_type = self.__simpleContent(self.__pendingDerivationMethod)
content_type = self.__simpleContent(self.__derivationMethod)
if content_type is None:
self._queueForResolution('restriction of unresolved simple type')
return self
Expand All @@ -2547,7 +2544,7 @@ def _resolve (self):
return self
self.__contentType = (self.__contentType[0], prt._adaptForScope(self, self))

return self.__completeProcessing(self.__pendingDerivationMethod, self.__contentStyle)
return self.__completeProcessing(self.__derivationMethod, self.__contentStyle)

def pythonSupport (self):
"""Complex type definitions have no built-in type support."""
Expand Down

0 comments on commit b20fe61

Please sign in to comment.