[Pier] Simplest persistency layer

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

[Pier] Simplest persistency layer

Damien Cassou-3
Hi,

since the current persistency models do not work (at least for me), I
have created my own which saves the image on each modification:

PRPersistency suclass: #PRSaveImagePersistency
     ...

PRSaveImagePersistency>>snapshot
   [SmalltalkImage current snapshot: true andQuit: false]
        forkAt: Processor userBackgroundPriority

PRSaveImagePersistency>>log: aContext
   self snapshot

PRSaveImagePersistency>>do: aBlock



Nothing more

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Ramon Leon-4
> Hi,
>
> since the current persistency models do not work (at least for me), I
> have created my own which saves the image on each modification:
>
> PRPersistency suclass: #PRSaveImagePersistency
>      ...
>
> PRSaveImagePersistency>>snapshot
>    [SmalltalkImage current snapshot: true andQuit: false]
>         forkAt: Processor userBackgroundPriority
>
> PRSaveImagePersistency>>log: aContext
>    self snapshot
>
> PRSaveImagePersistency>>do: aBlock

try this for do: and reverseDo:

do: aBlock
     contexts do: [:each |
         aBlock value: (each setKernel: self kernel; yourself)]

reverseDo: aBlock
     contexts reverseDo: [:each |
         aBlock value: (each setKernel: self kernel; yourself)]

and you'll at least get history working.  The code in the
PRImagePersistency is wrong and doesn't work, this code will.  I checked
in these changes once but Lucas never merged them so they were lost
leaving the PRImagePersistency non functional.

I tried digging into this once myself and fixing PRFilePersistency, but
ran into problems I couldn't get around, here's the relevant info if you
want to take a crack at it.

PRFilePersistency>>do: aBlock
        "There's a bug in deserialization that leaves commands with no fields
or context, this causes an error which despite the ensure below, leaves
the filestream open preventing any further use of that file, at which
point fileNamed returns nil for all future calls. I'm returning self to
prevent an error, the gc does eventually close the file and things start
working again.  I think the bug is actually in the MABinaryWriter when
it serializes the command"

     | fileStream |
     fileStream := self directory fileNamed: self logFilename.
     fileStream ifNil: [^self].
       
     [[fileStream atEnd] whileFalse:
         [aBlock value: ((MABinaryReader read: fileStream)
             setKernel: self kernel;
             yourself)]]
         ensure: [fileStream close]

and...

PREditCommand>>write: anObject using: aDescription
     "this guard clause prevents this command from blowing up the
deserialization of commands in PRFilePersistency, which is currently
buggy for some reason, will remove once I chase down the error. - rjl"
     context ifNil:[^self].
     ^ (self description includes: aDescription)
         ifFalse: [ super write: anObject using: aDescription ]
         ifTrue: [ self fields at: aDescription put: anObject ]

Currently the lack of persistence is a serious show stopper with Pier,
hopefully Lucas, or someone with the necessary know how can find some
time in the near future to fix this.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Damien Cassou-3
Hi Ramon,

Ramon Leon wrote:

>> since the current persistency models do not work (at least for me), I
>> have created my own which saves the image on each modification:
>>
>> PRPersistency suclass: #PRSaveImagePersistency
>>      ...
>>
>> PRSaveImagePersistency>>snapshot
>>    [SmalltalkImage current snapshot: true andQuit: false]
>>         forkAt: Processor userBackgroundPriority
>>
>> PRSaveImagePersistency>>log: aContext
>>    self snapshot
>>
>> PRSaveImagePersistency>>do: aBlock
>
> try this for do: and reverseDo:
>
> do: aBlock
>      contexts do: [:each |
>          aBlock value: (each setKernel: self kernel; yourself)]
>
> reverseDo: aBlock
>      contexts reverseDo: [:each |
>          aBlock value: (each setKernel: self kernel; yourself)]



you probably misunderstood what I did. In fact, I propose a completely
new persistency model that has nothing to do with PRImagePersistency
(mine is called PRSaveImagePersistency).

This persistency layer saves the image every time the model is modified.
It doesn't manage concurrence nor recovering after a bad snapshot.

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

RE: [Pier] Simplest persistency layer

Ramon Leon-5
>
> you probably misunderstood what I did. In fact, I propose a
> completely new persistency model that has nothing to do with
> PRImagePersistency (mine is called PRSaveImagePersistency).
>
> This persistency layer saves the image every time the model
> is modified.
> It doesn't manage concurrence nor recovering after a bad snapshot.


No, I understood what you were doing, you misunderstand what my suggestion
offers.  With your save image persister, if you use the do and reverseDo I
suggest, the change and history views for a page will work, which they
currently don't.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Damien Cassou-3
Ramon Leon wrote:

>> you probably misunderstood what I did. In fact, I propose a
>> completely new persistency model that has nothing to do with
>> PRImagePersistency (mine is called PRSaveImagePersistency).
>>
>> This persistency layer saves the image every time the model
>> is modified.
>> It doesn't manage concurrence nor recovering after a bad snapshot.
>
>
> No, I understood what you were doing, you misunderstand what my suggestion
> offers.  With your save image persister, if you use the do and reverseDo I
> suggest, the change and history views for a page will work, which they
> currently don't.


Oooops, I'm really sorry. What makes me understand that you did not
understand was the reference to the variable 'contexts' which only
exists in PRImagePersistency. So your code won't work on my persistency
layer. What do I need to change to get the history ?


Thanks

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

RE: [Pier] Simplest persistency layer

Ramon Leon-5
>
>
> Oooops, I'm really sorry. What makes me understand that you
> did not understand was the reference to the variable
> 'contexts' which only exists in PRImagePersistency. So your
> code won't work on my persistency layer. What do I need to
> change to get the history ?
>
>
> Thanks


You should really just subclass PRImagePersistency, use the do and reverseDo
I sent, and override snapshot and log with your versions.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Damien Cassou-3
Ramon Leon wrote:

>>
>> Oooops, I'm really sorry. What makes me understand that you
>> did not understand was the reference to the variable
>> 'contexts' which only exists in PRImagePersistency. So your
>> code won't work on my persistency layer. What do I need to
>> change to get the history ?
>>
>>
>> Thanks
>
>
> You should really just subclass PRImagePersistency, use the do and reverseDo
> I sent, and override snapshot and log with your versions.

Should #log: call super to fill the context collection ?

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Ramon Leon-4
Damien Cassou wrote:

> Ramon Leon wrote:
>
>>>Oooops, I'm really sorry. What makes me understand that you
>>>did not understand was the reference to the variable
>>>'contexts' which only exists in PRImagePersistency. So your
>>>code won't work on my persistency layer. What do I need to
>>>change to get the history ?
>>>
>>>
>>>Thanks
>>
>>
>>You should really just subclass PRImagePersistency, use the do and reverseDo
>>I sent, and override snapshot and log with your versions.
>
>
> Should #log: call super to fill the context collection ?
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>
>

Yes, and snapshot as well, you're overriding log and snapshot simply to
extend them, not replace them.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Lukas Renggli-2
In reply to this post by Ramon Leon-4
> Currently the lack of persistence is a serious show stopper with Pier,
> hopefully Lucas, or someone with the necessary know how can find some
> time in the near future to fix this.

Yes, I know about this problem.

I finished with my master studies at the university and will start  
with a PhD tomorrow. This means, I will be probably able to allocate  
time on this, but I don't know yet how much and when. Definitely I  
will need to concentrate on other things as well, so I am more  
limited than before.

Of course, contribution/fixes/enhancements are always welcome.  
Remember, the repository is open for anybody to publish his/her changes.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

RE: [Pier] Simplest persistency layer

Ramon Leon-5
>
> Of course, contribution/fixes/enhancements are always welcome.  
> Remember, the repository is open for anybody to publish
> his/her changes.
>
> Cheers,
> Lukas

I did at one point, publish some fixes to the PRImagePersistency class, and
some comments to PRFilePersistency, you never merged them, so I've been
waiting for you to get around to fixing persistence.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pier] Simplest persistency layer

Lukas Renggli-2
>> Of course, contribution/fixes/enhancements are always welcome.
>> Remember, the repository is open for anybody to publish
>> his/her changes.
>>
>> Cheers,
>> Lukas
>
> I did at one point, publish some fixes to the PRImagePersistency  
> class, and
> some comments to PRFilePersistency, you never merged them, so I've  
> been
> waiting for you to get around to fixing persistence.

Yes, I do remember. I did not forget about them. The problem was that  
I could merge them only partly (I think I merged the Magritte  
changes, but not the ones of Pier) was that the changes introduced  
some comments that I didn't want to appear in the automatically  
generated documentation for my master.

Still Monticello makes it very easy to fork a version and eventually  
merge it back in later on. I am doing this all the time.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

RE: [Pier] Simplest persistency layer

Ramon Leon-5
>
> Yes, I do remember. I did not forget about them. The problem
> was that I could merge them only partly (I think I merged the
> Magritte changes, but not the ones of Pier) was that the
> changes introduced some comments that I didn't want to appear
> in the automatically generated documentation for my master.
>
> Still Monticello makes it very easy to fork a version and
> eventually merge it back in later on. I am doing this all the time.
>
> Lukas

Oh I know, I maintain my own fork with those changes locally, Monticello
rocks.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki