[Soap-Python] Self referencing object & simpleContent question

Tsah Zelenka tsah at pheer.it
Fri Jul 22 00:18:17 CEST 2011


On Thu, 21 Jul 2011 10:23:33 +0300
Burak Arslan <burak.arslan at arskom.com.tr> wrote:

> ----- Original message -----
> > To self reference a a complex type, you hace to use something like :
> > 
> > class Foo(ComplexModel):
> >       bar = None
> > 
> > Foo.bar = Foo

It's not working (wrong wsdl and meaningless attribute when used)

> class Foo(ComplexModel):
>     class Attributes(ComplexModel.Attributes)
>         attr = String
> 
> Foo._type_info['bar'] = Foo
> 
> if i'm not mistaken. check with the source code.

Ok that's working, but it's not very straightforward (and undocumented)
so yesterday i was messing around with the src code and forked soaplib
on github. I came with this (so far, it's working) :
https://github.com/tzelen/soaplib/commit/eb9f910458d6d1df3f4b54c2c84a82cb63e4171a

Example : 
class Object(ClassModel):
    value = AutoRef
# value will be Object in the wsdl generation and in the xml objects.

With _type_info explained here I looked to patch
ClassModelMeta.__new__() to add an exception in the "populate soap
member" section to accept something like 'self' (django model style)
to do the self referencing. I think it would be simple and easy, but
since the type is only created at the end of __new__(), it need a
2-pass algorithm and would probably be ugly.

Any thought on adding a mechanism for the self referencing vs editing
_type_info by hand?

Best regards,
T.


More information about the Soap mailing list