On 06/07/2012 05:14 PM, ShaoHe Feng wrote:
as we all know the current params.py was not completely by the
generateSD.py, there are parts that have to be updated manually.
now I have post a primarypatch to improve it.
it can generate some codes, but still two parts codes can not be generated.
they aretwo dictionaries: _rootClassMap and _elementToClassMap.
However, for I do get any clue to know these two dictionaries from the
The reason for these dictionaries is that "generateDS.py" generates
classes for the complex types inside the API .xsd, but it doesn't
generate anything for the tags that can appear as root tags in the XML
documents used by the API. The map helps the parser find the classes
that correspond to each of those tags.
It might be possible to generate this map from the list of classes using
a rule like this:
CamelCaseName -> camel_case_names
But there are exceptions like these:
VLAN -> vlan
IPs -> ips
IscsiDetails -> iscsi
You could write code that takes into account the exceptions and
generates the map. But I think it is not worth, and error prone. I would
rather take that chunk of code out of params.py and move it to an
external file or to a constant, like you do for other chunks of code in
there are some questions:
And the __all__ list which include all the classes of _rootClassMap and
And there some classes both in _rootClassMap and _elementToClassMap.
The "__all__" list is just a python mechanism to control the symbols
that are imported when you do something like "from whatever import *".
In this case "generateDS.py" is making sure that all the generated
classes are imported, which is not really relevant for us.
And some of class in _rootClassMap inherit GeneratedsSuper class, some
inherit BaseResource class, and two classes inherit Link class.
And it is the same with _elementToClassMap.
so what is the difference between _rootClassMap and _elementToClassMap.
What rule to generate these two dictionaries.
I can't find any difference between those two dictionaries, they serve
exactly the same purpose. Maybe Michael had a future use in mind.
And also, how to generate the keys in _rootClassMap and
_elementToClassMap.Any rule to generate them?
there are some items in these two dictionaries
AccessControlList, # "_" among the word in key
"api" : API,
"body" : Body,
IscsiDetails, # key "iscsi" is one part of value
"storage_domain" : StorageDomain,
"topology" : CpuTopology,
"creation_status" : Status, #
key has a more word "creation" than the value.
"parent" : TagParent
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.