[Seaside] Application context

Ramon Leon ramon.leon at allresnet.com
Mon May 18 03:35:12 UTC 2009

> There are a few different ways for objects to get a dependency,
> looking up a singleton is only one of them.  I'd prefer not to use it.
>  Let me show you some fake code that should hopefully demonstrate what
> I want to do better than I've explained it so far.
> MyBlogApp new userRepository: UserRepository new;
>    mountAt: '/us/blog';
>    run.
> MyBlogApp new userRepository: UserRepository new;
>    mountAt: '/ca/blog';
>    run.
> Each of those is an instance of my blog app, and runs separately from
> the other.  The userRepository automatically gets injected into the
> components that make up the application.  This way they can just look
> up their local instance variable as opposed to grabbing a singleton.
> Is that clearer?  That's the gist of what I'm trying to do.  Now I
> just need to know how to do it with Seaside.
> Pat

Ah, I see, you're wanting to be involved in the creation of the root
instance of your component and hand in the dependency there.  What you're
looking for is a custom render loop, subclass WARenderLoopMain so you can
override #createRoot and control the creation of your component.  Then you
can pass in any dependencies you like during the construction of your

You can plug in your render loop during the registration of your app on a
mount point.

YourRootClass class>>initialize
    | app |
    app := self registerAsApplication: 'someAppName'.
    app preferenceAt: #mainClass put: YourRenderLoop.
    ^ app

Ramon Leon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20090517/a9c4c621/attachment.htm

More information about the seaside mailing list