[lxml-dev] lxml 1.3 coming up
jholg at gmx.de
jholg at gmx.de
Thu Jun 21 18:52:52 CEST 2007
Hi,
> And I think I've found another thing that could be changed: The
> DataElement()
> does not treat None arguments the way normal direct assignment does,
> setting xsi:nil="true". Instead it returns this:
>
> >>> root.n = DataElement(None)
> >>> print root
> root = None [ObjectifiedElement]
> n = None [NoneElement]
> * py:pytype = 'none'
>
Find attached a patch that:
- changes the above to apply xsi:nil="true" for None value arguments
- lets DataElement() graciously handle ObjectifiedDataElement arguments, keeping their attributes intact, if not overridden by the DataElement() args. This also reuses existing xsi:type or py:pytype information, unless _pytype and/or _xsi are provided as parameters to DataElement()
Previously, DataElement() cut off all attributes if given an ObjectifiedDataElement instance.
- Type-checks the _value against the given type hint:
>>> objectify.DataElement(273.34, _xsi="int")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "objectify.pyx", line 1742, in objectify.DataElement
ValueError: invalid literal for int(): 273.34
>>>
You will run into the error anyway - sooner or later - when accessing the .pyval in any way, so why not during instantiation.
Tests are included for the described behaviour.
Additionally, I've revamped some of the tests I provided earlier and split them up: More but smaller test methods now.
Please try it out, if any of the DataElement changes are not ok I can also send only the split-up tests, of course.
Btw.: I'm always getting
IOError: Error reading file '/data/pydev/hjoukl/LXML/lxml-1.3/src/lxml/tests/test_xinclude.xml': failed to load external entity "/data/pydev/hjoukl/LXML/lxml-1.3/src/lxml/tests/test_xinclude.xml"
due to some missing xml file lately when running the tests.
Holger
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DataElement_arg_split_tests.patch
Type: application/octet-stream
Size: 15832 bytes
Desc: not available
Url : http://codespeak.net/pipermail/lxml-dev/attachments/20070621/08125d8a/attachment.obj
More information about the lxml-dev
mailing list