How to store live objects in Monticello?

Milan Zimmermann milan.zimmermann at sympatico.ca
Tue Feb 13 06:35:44 UTC 2007


On 2007 February 12 08:06, Bert Freudenberg wrote:
> A workaround would be to put that string into a method, and
> unserialize the project into the class var in the class-side
> #initialize.

Yes, this is basically what I am trying to do now. Basically (sort of ) a copy 
and paste from the live string into a method and adding ^'' around (through a 
ByteArray and a few hoops, as I cannot just copy and paste).

Speaking of copy/paste: When I do Alt-p on something like:

(ProjectsToTestContainer getContainedProjectHolders at: 1) getProject

It shows something like:

a ByteArray(80 75 3 4 20....etc...)

when the result is very long, it shows "...etc" at the end. Same if I print to 
Transcript. Is there some way to force showing all the contents?

>
> A totally hackish thing would be to include the project file in the
> MCZ, which is just a ZIP archive after all, and when #initialize is
> called on your class, walk up the call chain to find the Monticello
> instance that initiated the load - peek into its innards to get at
> the file ;-)

Maybe not as hackish ;) I think this would allow a less "manual" process when 
adding another project to test.

Thanks Milan
>
> - Bert -
>
> On Feb 12, 2007, at 13:50 , Milan Zimmermann wrote:
> > Mathew,
> >
> > do you mean class-side initilization that would run when the MCZ is
> > loaded in
> > the image on the "target" system? If so, that is not what I am
> > looking for -
> > I am explicitly trying to initialize that member only on the first
> > system
> > that creates the MCZ. In more detail, when creating resource for
> > the test, I
> > stream eToys .pr file into a String, and the tests then stream
> > Projects from
> > this string as if they were loading the .pr file. The reason I need
> > that, is
> > I cannot (and do not want to) ship these .pr files around with the
> > tests.
> >
> > Milan
> >
> > On 2007 February 12 00:27, Matthew Fulmer wrote:
> >> On Sun, Feb 11, 2007 at 10:07:48PM -0500, Milan Zimmermann wrote:
> >>> Hi,
> >>>
> >>> I am trying to do something like this: I have a class
> >>> LoadProjectTest
> >>> that is essentially a singleton and the LoadProjectTest  class is in
> >>> category eToys-Tests. I'd like to do something like this: In the
> >>> image
> >>> where this class originates, I am creating the instance, and
> >>> setting one
> >>> instance variable with some value from a local file. I'd like the
> >>> instance to be stored in Monticello, when I "save" the category.
> >>> Then,
> >>> when the MCZ is loaded into another image, the instance would be
> >>> there,
> >>> filled with the value as created in the originating image.
> >>>
> >>> However, when I load the MCZ into another image, the instance is
> >>> null;
> >>> although I was assuming otherwise, that makes sense as the
> >>> Monticello
> >>> repository stores code not live objects.
> >>>
> >>> Is it possible to, somehow, to make Monticello to keep the
> >>> instance, so
> >>> it is deserialized from the MCZ when the MCZ is loaded into the
> >>> target
> >>> image?
> >>
> >> You would write some class initialization code that creates this
> >> instance, and stores it where you see fit. Put your code in the
> >> class-side initialize method.
> >>
> >> A good example of a code that does just that is the class
> >> ExternalType in category FFI-Kernel. Look at the methods in
> >> category "class initialization"
> >>
> >>> Thanks Milan
> >>
> >> Hope it helps.



More information about the Squeak-dev mailing list