Sorry for the noise -- I've got other strange stuff going on so I'm going to shut up and retract my observations since I am not sure just _what_ is going on in this setting.
 
A red-faced
 
Alanl
 
 
-----
Alan Littleford alan@littleford.net
(650)-255-6909
-----Original Message-----
From: jython-users-admin@lists.sourceforge.net [mailto:jython-users-admin@lists.sourceforge.net]On Behalf Of Alan Littleford
Sent: Tuesday, June 04, 2002 1:01 PM
To: Jython-users
Subject: RE: [Jython-users] serialization woes ...

Just a clarification -- the methods extracted below were taken out of a bigger class -- hence the 'self' variables.
 
Tnx
Alanl
-----Original Message-----
From: jython-users-admin@lists.sourceforge.net [mailto:jython-users-admin@lists.sourceforge.net]On Behalf Of Alan Littleford
Sent: Tuesday, June 04, 2002 11:19 AM
To: Jython-users
Subject: [Jython-users] serialization woes ...

I have a python class whose instance variables may contain 'raw' Java objects and I need to serialize this class to/from a file. Since Pickle doesn't Pickle Java classes I followed the advice around this board and serialize using:
 
 def dumpf(self, obj, fname):
  """Serializes object to file"""
  io.ObjectOutputStream(io.FileOutputStream(fname)).writeObject(obj)
  
 def restoref(self, fname):
  """Restores serialized object in file"""
  inStream = org.python.util.PythonObjectInputStream(io.FileInputStream(fname)) 
  return inStream.readObject()  
 
However I seem to be having problems on the _dump_ side. Examining the binary file shows that certain instance variables aren't always showing up depending on their contents ('dict' objects seem unreliable in this regard - if an instance variable has value {} the variable doesn't appear at all in the binary).
 
Is there a reliable way of serializing an instance of a  Python class that may have raw Java objects in instance variables. I'm using Jython 2.1. on JDK 1.3 on Win 2K.
 
Tnx
Alanl