[Seaside] How to add GLORP to a Seaside application?
rh at 4096.sk
Mon Jan 31 16:12:20 CET 2005
On Mon, 31 Jan 2005, Martin J.Laubach wrote:
> glorpSession beginUnitOfWork.
> UserView>>renderContentOn: html
> html unorderedList:
> [(s readManyOf: User) do:
> [:ea |
> html listItem:
> [html text: ea username.
> html space.
> html anchorWithAction: [ea password: 'xxx'. glorpSession
> commitUnitOfWork. glorpSession beginUnitOfWork. ]
> text: 'reset pw']]].
That would work, except you probably don't want to read the database in
renderContentOn: (db access every time you display the page, and you
already have the objects in memory after the first time). WATableReport
might be handy for what you're doing, as it caches the rows.
However, once you don't read db every time, you can no longer rely on the
auto-registering via readManyOf:.
My code would have something like
[self myUsers "lazy-init read, cached in instvar" do:
[html text: ea username.
html anchorWithAction: [self inUnitOfWork: [glorSession register: ea. ea password: 'xxx']]
text: 'reset pw']]].
where inUnitOfWork: aBlock is simply
This has the advantage that you don't "block" the unit of work when you
don't need it, so when the user forks a second browser window, it won't
crash (as your #beginUnitOfWork would in #initialize)
More information about the Seaside