[Seaside] Re: How to add GLORP to a Seaside application?
andrei.sobchuck at gmail.com
Wed Mar 23 16:56:36 CET 2005
Martin J. Laubach <mjl at laubach.at> wrote:
MJL> | begin unit of work
MJL> | register original object
MJL> | replay changes from the copy to the original
MJL> | commit unit of work
MJL> Yes, that's what I ended up with too. It's pretty much manual
MJL> copying right now for me, I'll think about automation when it gets
MJL> too tedious.
MJL> Ie., when the user hits "Save" or "Abort", I do something like
MJL> glorpSession modify: myObject
MJL> in: [ myObject copyDataFrom: formData ].
MJL> | So... on one side I'm glad to have it, because it (mostly) works and I
MJL> | don't have anything better. On other side, I'm unhappy about it because
MJL> | it's ugly and I don't have anything better.
MJL> My feelings exactly. I wish glorp could do multiple UnitOfWorks,
MJL> well, at least something's left to wish for...
Some times ago I've tryied to implement multiple UnitOfWorks
in one glorp session, and I think it's impossible.
There are 2 reasons for such conclusion:
1. When an object registered in an unit of work then
real object, but not the copy, is returned.
This behaviour don't allow to work with one object
in several threads.
2. Even, if an unit of work will return the copy of
registered object, even in that case it's impossible
to isolate unit of works because a unit of work
registers not only one object, but all 'sub' objects.
And you don't controll that process.
Suppose, there are 2 object: B->A->C and C'->A->B.
In first UnitOfWork changes to B and A are commited,
in second one changes to C' are rolled back.
And rolled back all changes to A and B as well.
Not sure you like it.
So, the only way to work is to create copies of objects.
You can 'manually' copy, or use BufferedValueHolder.
In seaside/vw I think about using a collection of MessageSend.
textInputFor: aSymbol label: aString on: html
| initialValue |
initialValue := value perform: aSymbol.
html textInputWithValue: initialValue
callback: (self callbackFor: aSymbol
callbackFor: aSymbol initialValue: initialValue
[:v | initialValue = v
ifFalse: [changes add: (self setterFor: aSymbol value: v)]]
setterFor: aSymbol value: v
| setSelector |
setSelector := (aSymbol , ':') asSymbol.
self glorpSession transact:
[self glorpSession register: value.
changes do: #value].
self textAreaFor: #txt label: 'Some text: ' on: html
It allows to collect changes from several pages
and commit in one transaction.
So, which schema is harder to implement, with coping of objects
or collecting message sends?
JabberID: andreis at jabber.ru. ICQ UIN: 46466235.
More information about the Seaside