[Seaside] How to add GLORP to a Seaside application?

radoslav hodnicak rh at 4096.sk
Tue Feb 1 17:36:08 CET 2005


On Tue, 1 Feb 2005, Martin J.Laubach wrote:

>    I'm afraid I painted myself in yet another corner with GLORP and
> Seaside.
>
>    The problem is that glorp does not support nesting of UnitOfWorks.
> That, together with the highly dynamic behaviour of Seaside
> applications,
> leads to my losing much hair...

Well yeah, you will lose much hair. Did you expect things to be easy?

Anyhow, after a year of trying various ways to deal with the issue of
nested editors I'm currently using glorp's descriptor to create deep
copies of the edited object (only fields mapped by glorp get copied) and
then only in the case when I want to save the changes to db I do something
like

begin unit of work
register original object
replay changes from the copy to the original
commit unit of work

resp. there is some logic to work with a chain of deep copies so that the
changes are only commited to db in the "topmost" editor.

On cancel I don't do anything, the original is unchanged and the deep copy
gets GCed.

advantages:
- every editor works with own set of data, the user can fork browsers and
save/cancel data however he wants to
- prevents partially changed and uncommited objects in the case where the
user just hits the back button to break from a form instead of save/cancel
button
- all unit of work work happens in a callback so there is no problems with
other components holding the UoW

disadvantages:
- memory hungry. deep copies of everything take a lot of space. my
production image went from about 40MB runtime to 180MB runtime
- very tricky to get the copying and replaying right. in fact I wansn't
able to make it work correctly with glorp's proxies so I don't use proxies
anymore
- deep copies create a MESS when it comes to object identity (one of the
main points in glorp)


So... on one side I'm glad to have it, because it (mostly) works and I
don't have anything better. On other side, I'm unhappy about it because
it's ugly and I don't have anything better.

rado



More information about the Seaside mailing list