[GS/SS Beta] Hook before moving an object to disk?

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

[GS/SS Beta] Hook before moving an object to disk?

Mariano Martinez Peck
Hi,

Is there a hook method I can implement in my class so that an instance receives a certain message just before being written to disk?

Reply | Threaded
Open this post in threaded view
|

Re: [GS/SS Beta] Hook before moving an object to disk?

Dale Henrichs-3
Mariano,

Not exactly, but depending upon what you are trying to do there may be an answer...For example you can see which objects are dirty at any point in time, so you could arrange to do something with that list before you do a commit ...

Dale


From: "Mariano Martinez Peck" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Monday, December 2, 2013 5:51:48 AM
Subject: [GS/SS Beta] Hook before moving an object to disk?

Hi,

Is there a hook method I can implement in my class so that an instance receives a certain message just before being written to disk?


Reply | Threaded
Open this post in threaded view
|

Re: [GS/SS Beta] Hook before moving an object to disk?

Mariano Martinez Peck



On Mon, Dec 2, 2013 at 6:52 PM, Dale K. Henrichs <[hidden email]> wrote:
Mariano,

Not exactly, but depending upon what you are trying to do there may be an answer...For example you can see which objects are dirty at any point in time, so you could arrange to do something with that list before you do a commit ...


Hi Dale,

Ok, so let me explain. I have split my persistency is groups of objects that I call Databases. For certain reason that I don't want to enter in details, I have some hooks in my domain classes to ignore certain instance variables when persisting (probably they are some kind of cache or something). In Fuel, I can use #fuelIgnoredInstanceVariableNames in SIXX #sixxIgnorableInstVarNames etc.
I need to achieve the same in GemStone. As far as I know, you don't have transient at the instVar level but rather at class level. I know I have TransientValue. But...using TransientValue means:

- In #initialize methods (and probably setters of my original instVar) I need to set the TransientValue
- To each place where I was accessing the instVar now I need to access it by being sure I send #value and #value:

So I need to do that for each instVar that I want to ignore. And of course, to make the code continue to work in Pharo, I would need to simulate a TransientValue that simply holds an instvar 'value'....

So I thought that maybe if there was a hook method before my object was going to disk, I could simply nil those instVars and I didn't need to use TransientValue and change anything...

Maybe there is another workaround?

Thanks, 

 
Dale


From: "Mariano Martinez Peck" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Monday, December 2, 2013 5:51:48 AM
Subject: [GS/SS Beta] Hook before moving an object to disk?


Hi,

Is there a hook method I can implement in my class so that an instance receives a certain message just before being written to disk?





--
Mariano
http://marianopeck.wordpress.com
Reply | Threaded
Open this post in threaded view
|

Re: [GS/SS Beta] Hook before moving an object to disk?

Jon Paynter-2
Mariano,

What is the impact of just leaving these instvars populated?

Note that as soon as you do a #commit they are written to disk


On Mon, Dec 2, 2013 at 6:52 PM, Dale K. Henrichs <[hidden email]> wrote:
Mariano,

Not exactly, but depending upon what you are trying to do there may be an answer...For example you can see which objects are dirty at any point in time, so you could arrange to do something with that list before you do a commit ...


Hi Dale,

Ok, so let me explain. I have split my persistency is groups of objects that I call Databases. For certain reason that I don't want to enter in details, I have some hooks in my domain classes to ignore certain instance variables when persisting (probably they are some kind of cache or something). In Fuel, I can use #fuelIgnoredInstanceVariableNames in SIXX #sixxIgnorableInstVarNames etc.
I need to achieve the same in GemStone. As far as I know, you don't have transient at the instVar level but rather at class level. I know I have TransientValue. But...using TransientValue means:

- In #initialize methods (and probably setters of my original instVar) I need to set the TransientValue
- To each place where I was accessing the instVar now I need to access it by being sure I send #value and #value:

So I need to do that for each instVar that I want to ignore. And of course, to make the code continue to work in Pharo, I would need to simulate a TransientValue that simply holds an instvar 'value'....

So I thought that maybe if there was a hook method before my object was going to disk, I could simply nil those instVars and I didn't need to use TransientValue and change anything...

Maybe there is another workaround?
Reply | Threaded
Open this post in threaded view
|

Re: [GS/SS Beta] Hook before moving an object to disk?

Dale Henrichs-3
In reply to this post by Mariano Martinez Peck
Mariano,

No, I think that you've pretty much hit the limit ... If you always send a message to reference the inst vars, then you only need to touch the getter and setter (a good practice anyway, I would think) ... using a message for the getter also means that you can lazily initialize the transient value to a meaningful value ...

We have threatened to add a feature where you could make individual instance variables transient, but we figured that the existence of TransientValue would pretty much fill the bill..

If you do decide to add TransientValue on the Pharo side, there is a MockGemStone project[1] where you can share your implementation (pretty straightforward I would think) with others ...

If you've got a lot of this transient state, you might consider refactoring your class structure to isolate the transient instance variables in a separate class that can be declared transient (like TransientValue) then you can avoid having to "port" TransientValue to Pharo, but you'd still need to use setters/getters to hide this indirection ....

Another technique is to not use instance variables for your state. Instead you can store your state in appropriate slots in SessionTemps current ... SessionTemps is basically a transient root ...

Dale

[1] http://seaside.gemtalksystems.com/ss/MockGemStone.html


From: "Mariano Martinez Peck" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Tuesday, December 3, 2013 4:32:47 AM
Subject: Re: [GS/SS Beta] Hook before moving an object to disk?




On Mon, Dec 2, 2013 at 6:52 PM, Dale K. Henrichs <[hidden email]> wrote:
Mariano,

Not exactly, but depending upon what you are trying to do there may be an answer...For example you can see which objects are dirty at any point in time, so you could arrange to do something with that list before you do a commit ...


Hi Dale,

Ok, so let me explain. I have split my persistency is groups of objects that I call Databases. For certain reason that I don't want to enter in details, I have some hooks in my domain classes to ignore certain instance variables when persisting (probably they are some kind of cache or something). In Fuel, I can use #fuelIgnoredInstanceVariableNames in SIXX #sixxIgnorableInstVarNames etc.
I need to achieve the same in GemStone. As far as I know, you don't have transient at the instVar level but rather at class level. I know I have TransientValue. But...using TransientValue means:

- In #initialize methods (and probably setters of my original instVar) I need to set the TransientValue
- To each place where I was accessing the instVar now I need to access it by being sure I send #value and #value:

So I need to do that for each instVar that I want to ignore. And of course, to make the code continue to work in Pharo, I would need to simulate a TransientValue that simply holds an instvar 'value'....

So I thought that maybe if there was a hook method before my object was going to disk, I could simply nil those instVars and I didn't need to use TransientValue and change anything...

Maybe there is another workaround?

Thanks, 

 
Dale


From: "Mariano Martinez Peck" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Monday, December 2, 2013 5:51:48 AM
Subject: [GS/SS Beta] Hook before moving an object to disk?


Hi,

Is there a hook method I can implement in my class so that an instance receives a certain message just before being written to disk?





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