Re: [pyxb-users] Problem when importing schemas when there is a property called Namespace
Brought to you by:
pabigot
From: Peter B. <bi...@ac...> - 2013-02-27 20:23:44
|
The actual fix was slightly different but has the same effect on the bindings as what I recommended below. Details in the trac ticket. Peter On Wed, Feb 27, 2013 at 12:47 PM, Peter Bigot <bi...@ac...> wrote: > I've replicated this as http://sourceforge.net/apps/trac/pyxb/ticket/191 > > In pyxb/binding/basis.py add 'Namespace' to the _ReservedSymbols set in > the complexTypeDefinition class. > > As a consequence, the attribute "Namespace" will be spelled "Namespace_" > in the bindings, but that's consistent with how PyXB handles other XML > attribute/element names that conflict with identifiers reserved by either > Python or PyXB. > > Peter > > On Wed, Feb 27, 2013 at 10:55 AM, Vladimir Todorov <ins...@gm...>wrote: > >> Actually the global Namespace should not be overriden by the local >> declaration because it is local to the class - the code below the local >> declaration should use the global Namespace instead of the local Namespace >> One thing that comes to my mind is to have this in the bindings: >> >> ... >> globalNamespace = Namespace >> Namespace = property(__Namespace.value, __Namespace.set, None, >> u'none\nThe namespace of the API definition.\n false') >> >> and everything below that uses >> pyxb.namespace.ExpandedName(Namespace, ..) >> should be >> pyxb.namespace.ExpandedName(globalNamespace, ..) >> >> but I will have to change everything by hand and if I regenerate the >> schemas I will need to do it again. >> >> >> >> On Wed, Feb 27, 2013 at 6:26 PM, Vladimir Todorov <ins...@gm...>wrote: >> >>> Hi all, >>> >>> Today I hit a problem while I was trying to import the generated >>> bindings for a particular schema. After some debugging I found out that the >>> problem is actually with the schema - it defines a property called >>> "Namespace" (yep ..) and in the generated code there is something like >>> this: >>> >>> Namespace = property(__Namespace.value, __Namespace.set, None, >>> u'none\nThe namespace of the API definition.\n false') >>> >>> Now this is a problem because Namespace is expected to be of type >>> 'Namespace' but now it is of type 'property': >>> >>> File >>> "/usr/local/lib/python2.6/dist-packages/pyxb/namespace/__init__.py", line >>> 183, in __init__ >>> raise pyxb.LogicError('ExpandedName must include a valid (perhaps >>> absent) namespace, or None.') >>> >>> >>> On line 183 in this file we have: >>> >>> if (ns is not None) and not isinstance(ns, Namespace): >>> raise pyxb.LogicError('ExpandedName must include a valid >>> (perhaps absent) namespace, or None.') >>> >>> 'ns' will be of type 'property' because of the code above. >>> >>> >>> The 'Namespace' property overrides the 'Namespace' variable defined in >>> the beginning of the generated bindings: >>> Namespace = pyxb.namespace.NamespaceForURI(...) >>> >>> pyxbgen --version >>> pyxbgen from PyXB 1.1.4 >>> >>> Unfortunately I cannot modify the schemas because I am not the owner. >>> Does anyone know how I can fix this (easy way)? It is extremely >>> important for me. >>> >>> Regards, >>> Vladimir >>> >> >> >> >> ------------------------------------------------------------------------------ >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://p.sf.net/sfu/appdyn_d2d_feb >> _______________________________________________ >> pyxb-users mailing list >> pyx...@li... >> https://lists.sourceforge.net/lists/listinfo/pyxb-users >> >> > |