I have a Python module that creates two custom Tryton fields. When this 
module is imported, it calls  the *XMLRPCDecoder.register* method from 
*trytond.protocols.xmlrpc 
*to add a decoder method for my custom types. It also creates a marshalling 
function for xmlrpclib that puts the custom data into a struct so it can be 
sent over XMLRPC safely. 

When using one trytond instance as a client to another, the wire value of 
the custom type doesn't get translated back to the proper Python type like 
the decoder function would produce. That is, the decoder function is not 
called at all. 

When I use the python shell to script a client, I can receive properly 
translated data as long as I import the module before trying to make a 
request to the trytond server. If I send any data to the server with my 
custom type, the trytond server doesn't call the decoder method.

I know the module is imported and that the registration is still in place 
throughout the lifetime of the trytond process. I have verified this in my 
debugging attempts.

And, all of this worked fine in Tryton 3.2 and 3.4 prior to us upgrading to 
trytond 3.4.14. 

Admittedly, this is a fairly advanced usage of Tryton. So, I'll post some 
code that hopefully explains the problem better than I have done above.

# how does the custom type, a bitstring.BitArray object get translated to
# to some wire value before being sent over the wire and how it should get
# translated back

# produce the wire value put into xmlrpc struct
bitstr2wire = lambda o: {'__class__': 'bitstring', 'bin': o.bin}

# register the encoding function with xmlrpclib
xmlrpclib.Marshaller.dispatch[bitstring.BitArray] = \
        lambda self, value, write: self.dump_struct(bitstr2wire(value), 
write)

# produce the bitstring.BitArray object from the wire data
wire2bitstr = lambda dct: bitstring.BitArray(bin=dct['bin'])
# register the decoding function with Tryton's XMLRPC Decoder
XMLRPCDecoder.register('bitstring', wire2bitstr)


So, I'm asking if anyone knows of something that changed in trytond post 
3.4.7 that may affect this or maybe a change in the core Python xmlrpclib 
that causes the trytond based XMLRPCDecoder function to not get called. 

 

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/6e035488-1940-4ecb-b66c-ecbfd70dc3cc%40googlegroups.com.

Reply via email to