[Seaside] Seaside login - a write up
Avi Bryant
avi at beta4.com
Tue Sep 28 11:47:39 CEST 2004
On Sep 27, 2004, at 10:43 PM, Roger Whitney wrote:
> ---------- What not to do
>
> One might be tempted to avoid the overhead of using a session by doing:
>
> MyComponent>> renderContentOn: html
> user := self call: SeasideLogin new.
> Rest of your renderContentOn: code.
>
> At least in the VW version of Seaside, doing this makes the
> application unstable, so don’t do it.
Yes, sending #call: from a render method is a bad idea. Definitely
don't do that. Usually, the desire to do that is a sign that you
should be using a WATask. A task is a safe way to have the render
phase of a component trigger calls to other components. Components
that are subclasses of WATask don't ever render anything - as soon as
they are about to be rendered, their #go callback gets triggered
instead.
If you use a task, you don't need a custom session subclass for either
of your two techniques. In the case of using SeasideLogin, your Task
would look like this:
MyTask>>go
user := self call: SeasideLogin new.
self call: MyComponent new
In the case of using the builtin HTTP auth, it would look like this:
MyTask>>go
self session authenticateWith: CS683Authenticator during:
[self call: MyComponent new]
In both cases you simply need to set MyTask, instead of MyComponent, as
the root component of the application.
Avi
More information about the Seaside
mailing list