Persistence of data across sessions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Persistence of data across sessions

FunInRetirement
Hi there,

I completed the Bank Account tutorial written for Squeak. It worked fine but I have a question about persistence of data. After I built the bank account and gave it a balance history I saved and quit. Later I wanted to go back to it. The account and its details were gone and I could only create a new account.

How is data saved across sessions in Pharo?
Reply | Threaded
Open this post in threaded view
|

Re: Persistence of data across sessions

Jeff Gray
I don't know about that particular tutorial but if you saved the image then when you restart the objects will all still be in memory.

Perhaps there's a code issue. When you create an account is it referenced by anything? Maybe it's being gargbage collected when the app closes.
Difficult to say for sure without seeing the code.
Reply | Threaded
Open this post in threaded view
|

Re: Persistence of data across sessions

Stéphane Ducasse
In reply to this post by FunInRetirement
HI graham

there are different ways to do that.
you can use
        - a XMLWriter (See XMLSupport)
        - a binary object serializer (there smartref stream in the image but I sugest you to have a look at Fuel)
        - you can use storeOn: and readFromStream:
        (here the idea is that objects produce a texte representation of themslevs that when read using readFrom: recreate the object itself

Stef
       

On Sep 3, 2011, at 2:54 PM, graham telfer wrote:

> Hi there,
>
> I completed the Bank Account tutorial written for Squeak. It worked fine but I have a question about persistence of data. After I built the bank account and gave it a balance history I saved and quit. Later I wanted to go back to it. The account and its details were gone and I could only create a new account.
>
> How is data saved across sessions in Pharo?


Reply | Threaded
Open this post in threaded view
|

Re: Persistence of data across sessions

drush66
In reply to this post by FunInRetirement
On Sat, Sep 3, 2011 at 2:54 PM, graham telfer <[hidden email]> wrote:
> Hi there,
>
> I completed the Bank Account tutorial written for Squeak. It worked fine but
> I have a question about persistence of data. After I built the bank account
> and gave it a balance history I saved and quit. Later I wanted to go back to
> it. The account and its details were gone and I could only create a new
> account.
>
> How is data saved across sessions in Pharo?

I am bit puzzled by your question, since when you save Pharo image,
all your objects get saved, and when you load that image they are
still there live and kicking.

Your example sounds like it is for Seaside (since you mention
sessions) - which is web development framework. If that is correct,
seaside expires sessions after some time, for obvious reasons. So you
should make your data objects accessible from the seaside application,
not just current session.

Aside from that, if you would like to store your object also _outside_
of an image, there dozens of ways to accomplish that task. From simple
serialization to binary files (fuel and friends), serialization to
XML, object smalltalk databases (SandstoneDB, Magma), NoSQL databases
(CouchDB, and similar), to relational databases.

Davorin Rusevljan
http://www.cloud2'08.com/

Reply | Threaded
Open this post in threaded view
|

Re: Persistence of data across sessions

FunInRetirement
In reply to this post by Jeff Gray
Hi,

Maybe you are right about the garbage collector. This is the first thing I've tried in Smalltalk. I expected the image I saved would have the account details but no, I had to start over again and make a new account. It's not a big deal and I'll try some of the methods of storing data mentioned in other replies.

> Date: Mon, 5 Sep 2011 22:32:04 -0700

> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Pharo-users] Persistence of data across sessions
>
> I don't know about that particular tutorial but if you saved the image then
> when you restart the objects will all still be in memory.
>
> Perhaps there's a code issue. When you create an account is it referenced by
> anything? Maybe it's being gargbage collected when the app closes.
> Difficult to say for sure without seeing the code.
>
>
> --
> View this message in context: http://forum.world.st/Persistence-of-data-across-sessions-tp3787836p3792618.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Persistence of data across sessions

Mariano Martinez Peck


On Tue, Sep 6, 2011 at 2:21 PM, graham telfer <[hidden email]> wrote:
Hi,

Maybe you are right about the garbage collector. This is the first thing I've tried in Smalltalk. I expected the image I saved would have the account details but no, I had to start over again and make a new account. It's not a big deal and I'll try some of the methods of storing data mentioned in other replies.

But be aware that you do not need that. Just have an object that holds references to your objects and then they are not garbage collected, and hence, saving the image is enough.
For example, you can store them in a class side of a class. Say you have MyTutotial class and an calss var 'savedWhatever'. You can then store your root object there and that's all. I will be there when you load the imag again :)


 

> Date: Mon, 5 Sep 2011 22:32:04 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Pharo-users] Persistence of data across sessions

>
> I don't know about that particular tutorial but if you saved the image then
> when you restart the objects will all still be in memory.
>
> Perhaps there's a code issue. When you create an account is it referenced by
> anything? Maybe it's being gargbage collected when the app closes.
> Difficult to say for sure without seeing the code.
>
>
> --
> View this message in context: http://forum.world.st/Persistence-of-data-across-sessions-tp3787836p3792618.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>



--
Mariano
http://marianopeck.wordpress.com