[lxml-dev] objectify E-factory does not handle unicode text

Stefan Behnel stefan_ml at behnel.de
Thu Jul 5 22:08:40 CEST 2007



Stefan Behnel wrote:
> jholg at gmx.de wrote:
>> The E-factory has some strangeness to it regarding objectify:
>>>>> msg.x = objectify.E.INT(5,3,2)
>>>>> print objectify.dump(msg)
>> msg = None [ObjectifiedElement]
>>     x = 532 [IntElement]
>> but I don't think it makes sense to investigate. 
> 
> Hmmm, looks funny but is normal. This is how the factory works normaly:
> 
> http://codespeak.net/lxml/dev/tutorial.html#the-e-factory
> 
> It takes a content list as argument, so that's expected behaviour. ;)
>>
>> >>> def PYTYPE(value):
>> ...     if isinstance(value, ObjectifiedElement):
>> ...             return deepcopy(value) 
>> ...     else:
>> ...             return DataElement(value, type(value).__name__)
>> ... 
>> (Note: I don't like the name of that function yet...)
> 
> Good idea, we should add something like that to objectify - and definitely to
> the E-factory in objectify.

... which then should also fix the above problem, BTW.

Stefan



More information about the lxml-dev mailing list