[Kimchi-devel] [WIP PATCH 2/5] Register Kimchi's namespace when updating XML

Aline Manera alinefm at linux.vnet.ibm.com
Tue Oct 21 18:58:19 UTC 2014


On 10/17/2014 05:26 AM, Crístian Viana wrote:
> A domain's metadata content has a namespace assigned to it but that
> value is removed when the XML is updated using the function
> "kimchi.xmlutils.xml_item_update" because it doesn't know about the
> namespaces.
>
> Register the namespace "kimchi" with the appropriate value when updating
> XML using the function "kimchi.xmlutils.xml_item_update".
>
> Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
> ---
>   src/kimchi/xmlutils.py | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/kimchi/xmlutils.py b/src/kimchi/xmlutils.py
> index 00a9d55..8b19a20 100644
> --- a/src/kimchi/xmlutils.py
> +++ b/src/kimchi/xmlutils.py
> @@ -20,9 +20,10 @@
>   import libxml2
>   from lxml import objectify
>   
> -
>   from xml.etree import ElementTree
>   

> +import kimchi.model
> +

Instead of importing the whole module, import only the constants you 
need here.

>   
>   def xpath_get_text(xml, expr):
>       doc = libxml2.parseDoc(xml)
> @@ -34,6 +35,9 @@ def xpath_get_text(xml, expr):
>   
>   
>   def xml_item_update(xml, xpath, value):
> +    ElementTree.register_namespace(kimchi.model.utils.KIMCHI_NAMESPACE,
> +                                   kimchi.model.utils.KIMCHI_META_URL)
> +
>       root = ElementTree.fromstring(xml)
>       item = root.find(xpath)
>       item.text = value




More information about the Kimchi-devel mailing list