[Seaside] Application context
pat.maddox at gmail.com
Sun May 17 20:49:33 UTC 2009
Where's a good place for me to do one-time setup and then make certain
objects available to the rest of the application? I created a
UserRepository that I want each of the components to use. So far I've
created a base subclass of WAComponent, it has a class variable named
TheUserRepository. I have a class-side method which lazily
instantiates it. Then the instance initialize for each of my
components points an instance variable at this method. The code looks
TheUserRepository ifNil: [TheUserRepository := GDRepository for: ANUser].
userRepository := ANComponent userRepository.
All of my components inherit from ANComponent so they each have the
userRepository set when they're instantiated.
Is this a good way of doing it? It seems to be working so far. I
don't know enough about seaside to know better at this point :)
If possible, I'd like to move away from using a class variable to
store the repo. As it is, I can't deploy the same app twice at
different entry points because they'll use the same userRepository
object. So what I'd really like is an Application object that gets
run once, where I can do all my setup. But that application object
should be new for each deployment, so that I'm not mixing the data
Thanks for any help.
More information about the seaside