[lxml-dev] annotate, pyannotate, xsiannotate

Stefan Behnel stefan_ml at behnel.de
Tue Sep 18 10:42:19 CEST 2007


Hi Holger,

jholg at gmx.de wrote:
>> I think we should do this:
>>
>>                 if old_pytypename == TREE_PYTYPE:
>>                     if cetree.findChild(c_node, 0) is NULL:
>>                         pytype = TREE_PYTYPE
>>                 else:
>>                     # check old type
>>
>> Do you still think we need the keep_tree then?
> 
> You really don't like it, do you ;-)?
> I'd say this should work and remove the need for keep_tree, though.

Ok. I also added the tests from your patch now.

Obvious question then: anything still missing from what your last patch did?


> Sidenote: So I thought maybe we should revise the use of TREE in objectify in general, but one has to be very careful. You really want to have it e.g. in objectify.Element():

I think we should, and we should restrict its use to a minimum. If you want,
you can take a look at it. I don't feel like touching working code at the
moment. :)


>>>> o = objectify.Element("structural")
>>>> e = etree.Element("structural") 
>>>> type(o), type(e)
> (<type 'objectify.ObjectifiedElement'>, <type 'objectify.ObjectifiedElement'>)

Whatever. I don't want any code to rely on *that*. :)

(but I can see what your getting at)


>>>> root.o = o
>>>> root.e = e
>>>> # Now type lookup can not rely on parent == None
> ... 
>>>> type(root.o), type(root.e)
> (<type 'objectify.ObjectifiedElement'>, <type 'objectify.StringElement'>)

I'm not (any longer :) questioning the TREE type in general. I just think we
should not write annotations where we know we will not need them.

Stefan


More information about the lxml-dev mailing list