[Seaside] Application context
Ramon Leon
ramon.leon at allresnet.com
Mon May 18 01:44:19 UTC 2009
>
> "ANComponent userRepository"
> userRepository
> TheUserRepository ifNil: [TheUserRepository := GDRepository for:
> ANUser].
> ^ TheUserRepository
>
> "ANComponent>>initialize"
> initialize
> super initialize.
> userRepository := ANComponent userRepository.
>
>
I agree with James but I'll be more specific, how about this...
UserRepository class>>forApp: anApp
^ (Repository ifNil: [Repository := Dictionary new ])
at: anApp ifAbsentPut: [ GDRepository for: ANUser ]
ANComponent>>initialize
super initialize.
userRepository := UserRespository forApp: self session baseUrl
printString.
No need to stick the repository on a component class, create a unique class
just for it, you get an automatic singleton because classes *are* singletons
and why shouldn't a user repository be its own abstraction?
Ramon Leon
http://onsmalltalk.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20090517/0ce329c0/attachment.htm
More information about the seaside
mailing list