property in class must deconflict from module identifier #27

Closed
pabigot opened this Issue Jan 8, 2015 · 0 comments

Projects

None yet

1 participant

@pabigot
Owner
pabigot commented Jan 8, 2015

The following schema fragment:

<xs:simpleType name="name">
  <xs:restriction base="xs:string" />
</xs:simpleType>
<xs:element name="Container">
  <xs:complexType>
    <xs:attribute name="name" type="name"/>
    <xs:attribute name="name2" type="name"/>
  </xs:complexType>
</xs:element>

generates code where the attribute use of the name2 is defined using unadorned name as the type parameter. In context this resolves to the Container type property name corresponding to its attribute name, not the module-level simple type name.

@pabigot pabigot self-assigned this Jan 8, 2015
@pabigot pabigot added this to the PyXB 1.2.5 milestone Jan 8, 2015
@pabigot pabigot added a commit that closed this issue Feb 15, 2015
@pabigot fix #27: conflict between class property and module type name
When referencing the name of a binding type defined in the current odule
from a class also defined in the module we need to account for the
possibility that the class has defined a property with the same name.
At the user level these are not in conflict (because property access is
qualified by an object reference), but during the class definition this
qualifier is absent.

I'd rather just reference sys.modules[__name__] to get the module-level
definition, but when run with "setup.py test" python generates:

    AttributeError: 'module' object has no attribute 'color_'

even though the class 'color_' is completely defined before the class
that tries to reference it through the module object.  So we create a
holder for all type bindings defined in the module.
8fde40f
@pabigot pabigot closed this in 8fde40f Feb 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment