Package pyxb :: Package xmlschema :: Module structures :: Class _NamedComponent_mixin
[hide private]
[frames] | no frames]

type _NamedComponent_mixin

source code

                      object --+        
                               |        
                         cscRoot --+    
                                   |    
utils.utility.PrivateTransient_mixin --+
                                       |
                          object --+   |
                                   |   |
                             cscRoot --+
                                       |
                                      _NamedComponent_mixin
Known Subclasses:

Mix-in to hold the name and targetNamespace of a component.

The name may be None, indicating an anonymous component. The targetNamespace is never None, though it could be an empty namespace. The name and targetNamespace values are immutable after creation.

This class overrides the pickling behavior: when pickling a Namespace, objects that do not belong to that namespace are pickled as references, not as values. This ensures the uniqueness of objects when multiple namespace definitions are pre-loaded.

This class must follow _SchemaComponent_mixin in the MRO.

Instance Methods [hide private]
 
name(self)
Name of the component within its scope or namespace.
source code
 
isAnonymous(self)
Return true iff this instance is locally scoped (has no name).
source code
 
_setAnonymousName(self, namespace, unique_id=None, anon_name=None) source code
 
_anonymousName(self, namespace=None) source code
 
targetNamespace(self)
The targetNamespace of a component.
source code
 
bindingNamespace(self)
The namespace in which this component's binding is placed.
source code
 
_setBindingNamespace(self, namespace) source code
 
_templateMap(self)
A map from template keys to component-specific values.
source code
 
__needAnonymousSupport(self) source code
 
_schema(self)
Return the schema component from which this component was defined.
source code
 
_prepareForArchive_csc(self, module_record) source code
 
_picklesInArchive(self, archive)
Return True if this component should be pickled by value in the given namespace.
source code
 
_bindsInNamespace(self, ns)
Return True if the binding for this component should be generated in the given namespace.
source code
 
expandedName(self)
Return the pyxb.namespace.ExpandedName of this object.
source code
 
__init__(self, *args, **kw) source code
 
isNameEquivalent(self, other)
Return true iff this and the other component share the same name and target namespace.
source code
 
isTypeEquivalent(self, other)
Return True iff this and the other component have matching types.
source code
 
isDerivationConsistent(self, other)
Return True iff this type can serve as a restriction of the other type for the purposes of element consistency.
source code
 
_picklingReference(self) source code
 
__pickleAsReference(self) source code
 
__getstate__(self) source code
 
__getnewargs__(self)
Pickling support.
source code
 
__setstate__(self, state) source code
 
_resetClone_csc(self, **kw) source code
 
_NamedComponent_mixin__needAnonymousSupport(self) source code
 
_NamedComponent_mixin__pickleAsReference(self) source code
Static Methods [hide private]
 
__new__(cls, *args, **kw)
Pickling support.
source code
Class Variables [hide private]
  __PrivateTransient = set()
  __name = None
  __anonymousName = None
  __targetNamespace = None
  __bindingNamespace = None
  __templateMap = None
  __AnonymousCategory = pyxb.namespace.archive.NamespaceArchive....
  __schema = None
  _NamedComponent_mixin__AnonymousCategory = '_anonymousTypeDefi...
  _NamedComponent_mixin__PrivateTransient = set(['schema'])
  _NamedComponent_mixin__anonymousName = None
  _NamedComponent_mixin__bindingNamespace = None
  _NamedComponent_mixin__name = None
  _NamedComponent_mixin__schema = None
  _NamedComponent_mixin__targetNamespace = None
  _NamedComponent_mixin__templateMap = None
Method Details [hide private]

name(self)

source code 

Name of the component within its scope or namespace.

This is an NCName. The value isNone if the component is anonymous. The attribute is immutable after the component is created creation.

targetNamespace(self)

source code 

The targetNamespace of a component.

This is None, or a reference to a Namespace in which the component is declared (either as a global or local to one of the namespace's complex type definitions). This is immutable after creation.

_templateMap(self)

source code 

A map from template keys to component-specific values.

This is used in code generation to maintain unique names for accessor methods, identifiers, keys, and other characteristics associated with the code generated in support of the binding for this component.

_schema(self)

source code 

Return the schema component from which this component was defined.

Needed so we can distinguish components that came from different locations, since that imposes an external order dependency on them and on cross-namespace inclusions.

Note: This characteristic is removed when the component is stored in a namespace archive.

_picklesInArchive(self, archive)

source code 

Return True if this component should be pickled by value in the given namespace.

When pickling, a declaration component is considered to belong to the namespace if it has a local scope which belongs to the namespace. In that case, the declaration is a clone of something that does not belong to the namespace; but the clone does.

Returns:
False if the component should be pickled by reference.

See Also: _bindsInNamespace

_bindsInNamespace(self, ns)

source code 

Return True if the binding for this component should be generated in the given namespace.

This is the case when the component is in the given namespace. It's also the case when the component has no associated namespace (but not an absent namespace). Be aware that cross-namespace inheritance means you will get references to elements in another namespace when generating code for a subclass; that's fine, and those references should not be generated locally.

__new__(cls, *args, **kw)
Static Method

source code 

Pickling support.

Normally, we just create a new instance of this class. However, if we're unpickling a reference in a loadable schema, we need to return the existing component instance by looking up the name in the component map of the desired namespace. We can tell the difference because no normal constructors that inherit from this have positional arguments; only invocations by unpickling with a value returned in __getnewargs__ do.

This does require that the dependent namespace already have been validated (or that it be validated here). That shouldn't be a problem, except for the dependency loop resulting from use of xml:lang in the XMLSchema namespace. For that issue, see pyxb.namespace._XMLSchema.

Overrides: object.__new__

__init__(self, *args, **kw)
(Constructor)

source code 
Overrides: cscRoot.__init__

isNameEquivalent(self, other)

source code 

Return true iff this and the other component share the same name and target namespace.

Anonymous components are inherently name inequivalent, except to themselves. This relies on equivalence as defined for pyxb.namespace.ExpandedName, for which None is not equivalent to any non-anonymous name.

isTypeEquivalent(self, other)

source code 

Return True iff this and the other component have matching types.

It appears that name equivalence is used; two complex type definitions with identical structures are not considered equivalent (at least, per XMLSpy).

isDerivationConsistent(self, other)

source code 

Return True iff this type can serve as a restriction of the other type for the purposes of element consistency.

It appears that name equivalence is normally used; two complex type definitions with identical structures are not considered equivalent (at least, per XMLSpy). However, some OpenGIS standards demonstrate that derivation by restriction from the other type is also acceptable. That opens a whole can of worms; see ElementDeclaration.isAdaptable.

__getstate__(self)

source code 
Overrides: utils.utility.PrivateTransient_mixin.__getstate__

__getnewargs__(self)

source code 

Pickling support.

If this instance is being pickled as a reference, provide the arguments that are necessary so that the unpickler can locate the appropriate component rather than create a duplicate instance.


Class Variable Details [hide private]

__AnonymousCategory

Value:
pyxb.namespace.archive.NamespaceArchive._AnonymousCategory()

_NamedComponent_mixin__AnonymousCategory

Value:
'_anonymousTypeDefinition'