Modifying class definitions

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

Modifying class definitions

Alejandro Zuzek
Hi all,

I am having a problem after I tried to modify a class definition. The class in question is called CMTaks and the only change I made was add an instance variable called 'notified' and its accessors. I did that in Pharo and exported the changes with Monticcello and imported them in my glass instance with a code like this:

topaz 1> doit
| repository directory |
directory := FileDirectory on: '/home/glass'.
repository := MCDirectoryRepository new.
repository directory: directory.
(repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load.
%

and after that:
topaz 1> commit

The problem is, when I try to send the #'notified' message to a CMTimeActivatedTask instance, I get a 'does not understand' (and CMTimeActivatedTask is a subclass of CMTask). I know that that instance existed before I updated the CM-Model package with the code above.

On the other hand, if I create a new instance of CMTimeActivatedTask it does undersand #'notified' message. What is going on? I suspect it is related to transactions and somehow the instances of CMTimeActivatedTask that existed before the model was updated are still referring to the old class definition. If so, how can I solve this?

Thanks,

Alejandro
Reply | Threaded
Open this post in threaded view
|

Re: Modifying class definitions

Dale Henrichs-3
Alejandro,

You have run into one of the gotchas in GemStone ...

In Pharo classes are modified all instances of the class are automaticelly migrated.

In GemStone, we create a new instance of the class with new new instance variables, etc and we do not automatically migrate all instances of the class. We do this because we must be able to decouple class changes from the migration of instances ... In a large data base, the migration of instances may take a very long time since the entire db must be swept so automatic migration is not always feasible ...

For GLASS I have added auto-migration of instances as an OPTION. It is controlled by MCPlatformSupport class>autoMigrate. The default for autoMigrate is FALSE.

In GemTools auto migration is enabled by default, but in Topaz, it is disabled by default.

Before doing your install, you should set autoMigrate to true... There is a a helper class called GsDeployer that should probably be used:

  GsDeployer deploy: [
    | repository directory |
    directory := FileDirectory on: '/home/glass'.
    repository := MCDirectoryRepository new.
    repository directory: directory.
   (repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load ].

would have done the trick for you...

Dale



From: "Alejandro Zuzek" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Monday, May 20, 2013 5:39:30 PM
Subject: [GS/SS Beta] Modifying class definitions

Hi all,

I am having a problem after I tried to modify a class definition. The class in question is called CMTaks and the only change I made was add an instance variable called 'notified' and its accessors. I did that in Pharo and exported the changes with Monticcello and imported them in my glass instance with a code like this:

topaz 1> doit
| repository directory |
directory := FileDirectory on: '/home/glass'.
repository := MCDirectoryRepository new.
repository directory: directory.
(repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load.
%

and after that:
topaz 1> commit

The problem is, when I try to send the #'notified' message to a CMTimeActivatedTask instance, I get a 'does not understand' (and CMTimeActivatedTask is a subclass of CMTask). I know that that instance existed before I updated the CM-Model package with the code above.

On the other hand, if I create a new instance of CMTimeActivatedTask it does undersand #'notified' message. What is going on? I suspect it is related to transactions and somehow the instances of CMTimeActivatedTask that existed before the model was updated are still referring to the old class definition. If so, how can I solve this?

Thanks,

Alejandro

Reply | Threaded
Open this post in threaded view
|

Re: Modifying class definitions

Alejandro Zuzek
It worked like a charm and Gemstone is awesome!

Thanks


On Tue, May 21, 2013 at 3:08 PM, Dale K. Henrichs <[hidden email]> wrote:
Alejandro,

You have run into one of the gotchas in GemStone ...

In Pharo classes are modified all instances of the class are automaticelly migrated.

In GemStone, we create a new instance of the class with new new instance variables, etc and we do not automatically migrate all instances of the class. We do this because we must be able to decouple class changes from the migration of instances ... In a large data base, the migration of instances may take a very long time since the entire db must be swept so automatic migration is not always feasible ...

For GLASS I have added auto-migration of instances as an OPTION. It is controlled by MCPlatformSupport class>autoMigrate. The default for autoMigrate is FALSE.

In GemTools auto migration is enabled by default, but in Topaz, it is disabled by default.

Before doing your install, you should set autoMigrate to true... There is a a helper class called GsDeployer that should probably be used:

  GsDeployer deploy: [

    | repository directory |
    directory := FileDirectory on: '/home/glass'.
    repository := MCDirectoryRepository new.
    repository directory: directory.
   (repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load ].

would have done the trick for you...

Dale



From: "Alejandro Zuzek" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Monday, May 20, 2013 5:39:30 PM
Subject: [GS/SS Beta] Modifying class definitions


Hi all,

I am having a problem after I tried to modify a class definition. The class in question is called CMTaks and the only change I made was add an instance variable called 'notified' and its accessors. I did that in Pharo and exported the changes with Monticcello and imported them in my glass instance with a code like this:

topaz 1> doit
| repository directory |
directory := FileDirectory on: '/home/glass'.
repository := MCDirectoryRepository new.
repository directory: directory.
(repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load.
%

and after that:
topaz 1> commit

The problem is, when I try to send the #'notified' message to a CMTimeActivatedTask instance, I get a 'does not understand' (and CMTimeActivatedTask is a subclass of CMTask). I know that that instance existed before I updated the CM-Model package with the code above.

On the other hand, if I create a new instance of CMTimeActivatedTask it does undersand #'notified' message. What is going on? I suspect it is related to transactions and somehow the instances of CMTimeActivatedTask that existed before the model was updated are still referring to the old class definition. If so, how can I solve this?

Thanks,

Alejandro


Reply | Threaded
Open this post in threaded view
|

Re: Modifying class definitions

Alejandro Zuzek
Note to self: Class Creation, Versions and Instance Migration is explained in Chapter 9 of the Programming Guide (GS64-ProgGuide-3.0.pdf)


On Tue, May 21, 2013 at 11:24 PM, Alejandro Zuzek <[hidden email]> wrote:
It worked like a charm and Gemstone is awesome!

Thanks


On Tue, May 21, 2013 at 3:08 PM, Dale K. Henrichs <[hidden email]> wrote:
Alejandro,

You have run into one of the gotchas in GemStone ...

In Pharo classes are modified all instances of the class are automaticelly migrated.

In GemStone, we create a new instance of the class with new new instance variables, etc and we do not automatically migrate all instances of the class. We do this because we must be able to decouple class changes from the migration of instances ... In a large data base, the migration of instances may take a very long time since the entire db must be swept so automatic migration is not always feasible ...

For GLASS I have added auto-migration of instances as an OPTION. It is controlled by MCPlatformSupport class>autoMigrate. The default for autoMigrate is FALSE.

In GemTools auto migration is enabled by default, but in Topaz, it is disabled by default.

Before doing your install, you should set autoMigrate to true... There is a a helper class called GsDeployer that should probably be used:

  GsDeployer deploy: [

    | repository directory |
    directory := FileDirectory on: '/home/glass'.
    repository := MCDirectoryRepository new.
    repository directory: directory.
   (repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load ].

would have done the trick for you...

Dale



From: "Alejandro Zuzek" <[hidden email]>
To: "GemStone Seaside beta discussion" <[hidden email]>
Sent: Monday, May 20, 2013 5:39:30 PM
Subject: [GS/SS Beta] Modifying class definitions


Hi all,

I am having a problem after I tried to modify a class definition. The class in question is called CMTaks and the only change I made was add an instance variable called 'notified' and its accessors. I did that in Pharo and exported the changes with Monticcello and imported them in my glass instance with a code like this:

topaz 1> doit
| repository directory |
directory := FileDirectory on: '/home/glass'.
repository := MCDirectoryRepository new.
repository directory: directory.
(repository versionFromFileNamed: 'CM-Model-AlejandroZuzek.6.mcz') load.
%

and after that:
topaz 1> commit

The problem is, when I try to send the #'notified' message to a CMTimeActivatedTask instance, I get a 'does not understand' (and CMTimeActivatedTask is a subclass of CMTask). I know that that instance existed before I updated the CM-Model package with the code above.

On the other hand, if I create a new instance of CMTimeActivatedTask it does undersand #'notified' message. What is going on? I suspect it is related to transactions and somehow the instances of CMTimeActivatedTask that existed before the model was updated are still referring to the old class definition. If so, how can I solve this?

Thanks,

Alejandro