[Seaside] How to add GLORP to a Seaside application?
rh at 4096.sk
Sun Jan 30 22:56:58 CET 2005
On Sun, 30 Jan 2005, Martin J.Laubach wrote:
> Problem #2:
> MySubComponent>>renderContentOn: html
> | t |
> db transact: [
> t := readObjectFromDatabase.
> html anchorWithAction: [ t setSomeField: 'somevalue' ].
> self commitTransaction ]
I don't really understand what you're trying to do there but the generic
glorp usage looks like this
1) setup the connection to db, the result is initialized glorpSession (you
do this when the app starts/on first client connect)
2) on opening an editor (editor=anything that changes objects in a way
that should be stored in db) on object anObject
self glorpSession beginUnitOfWork.
self glorpSession register: anObject.
3) change anObject or objects referenced from it
4) closing the editor
on save "self glorpSession commitUnitOfWork"
on cancel "self glorpSession rollbackUnitOfWork"
5) repeat steps 2-4
6) clean-up on app exit
rollback will also change the objects in memory (as it should), not only
if you read any objects from db (readOneOf, readManyOf ...) while an unit
of work is active, said objects get #register:-ed (registering objects
tells glorp which objects to commit/rollback to db) automatically.
unit of works cannot be nested or run in parallel (meaning that you get an
exception if you beginUnitOfWork while there's already one)
the transact etc stuff you're trying to use is too low level.
next time try to write what you're trying to do, not how. my brain is
severely underclocked these days
gentleman, n. - a man who knows how to blog, but doesn't
More information about the Seaside