[omniORB] omiORBpy, pickles and strings

Gary Pennington Gary.Pennington@uk.sun.com
Tue, 03 Oct 2000 18:03:27 +0100


Hi,

I've sidestepped my original problem, I was generating my pickle using the
binary option and this was what was allowing NULL
characters to be inserted in the string. I've removed the binary option and
that means I get strings with no NULLS, which I can
return as a string to the client thus avoiding the expensive re-assembly.
For Python, it's kind of a neat way of doing Objects by
Value from a CORBA servant. Of course, it only works if your client is a
Python client (or can create objects from python
pickles) - but that's good enough for me.

If anyone has any comments on the questions I raised, I'd still appreciate
their feedback.

Thanks,

Gary

Gary Pennington wrote:

> Hi,
>
> I have to return an arbitrarily long stream of bytes to a client. (The
> bytes actually represent a pickled object, with the pickle having been
> stored in a Python string.)
>
> I can't just return a string, since the string may contain NULL values
> and language mappings for all languages don't allow NULLS in strings out
> of respect to C/C++. So instead, I shall declare the data to be a
> sequence of octets ( or should I declare it some other way?).
>
> The problem is that at the client side I have to re-assemble this data
> into a string, and this is painfully slow - too slow to be acceptable.
> However, in fact if my client is a cPython client, I don't have to do
> this re-assembly, however if it is a jPython client I do.
>
> This is a bit annoying since it is inconsistent, so before I start
> putting in the time to handle this differently-  I have 3 questions.
>
> 1. Is there a better way to pass a pickled representation from a server
> to a client than I describe?
> 2. If I have an interface that declares the following :-
>
>   typedef sequence<octet> octetSeq;
>   Blah blah blah...
>   octetSeq getState(in UserIF agent);
>
> Why do I get a string in a cPython client, whereas jPython behaves
> correctly and delivers up a pyArray of ints?
>
> 3. Should I be declaring my interface to return Any and casting down on
> the client end to a string?
>
> Further info, I am being naughty on the server and actually returning a
> string. Is this why it appears as a string at the cPython client? If so,
> why don't I also get a string at the jPython client and why isn't the
> error trapped on the server when I try to return the string? The jPython
> client is using stubs generated from the idlj compiler which is
> distributed as standard with JDK1.3.
>
> Gary