From: <an...@io...> - 2006-02-19 19:27:06
|
I read some of the old discussing actions. I'm not sure if I ever really laid out the problem space from my view, but I hope it can be somewhat clearly described this way: Actions are multi-purpose beings. We use them in the following forms: 1) Uses URL mapping. Called from the Controller. Does something which is defined by CTX->request. Let's call this a "Handler". 2) No url mapping. Called from an URL Handler. Does something which is defined by CTX->request and Action parameters. It produces a response. Let's call this a "Handler Call". 3) No url mapping. Called from an URL Handler. Does something which is defined purely by Action parameters. Let's call this a "Service Call". 4) No url mapping. Called from a Manage task. Does something which is defined purely by Action parameters. Let's call this a "Manage Call". URL Handler is the normal way of using an OI2 Action and Handler Call is a handy way to introduce page components (and maybe some functionality) from other packages. I think OI2 works for these two types of Actions. With Service and Manage Calls I have some small problems: The first problem comes with languages. By default the language is defined in CTX->request->language_handle, but I want to do my Manage and Service calls independent of the current request. So I should be able to set the language for my action. The second problem is Action "doing the right thing" in the case of a Service call. Action checks if CTX->request is present and does caching and message passing using the request if present. In Service calls I'd like to supply this information myself and it doesn't feel right to temporarily remove CTX->request each time I want to make a Service call. Then there is a nuissance with code reuse between Handlers and different Calls since Handlers and Handler Calls contain lots of references to CTX->request which can not be used with other Calls and which are not easy to "emulate". Since Handler Calls are probably the most common way to initially write functionality, you end up doing lots of refactoriung to your code when you need the same functionality as a Service Call or a Manage Call. Previously I had the suggestion that we should just add more accessors to the Action class so that we could emulate a request environment by assigning values to these accessors (which would otherwise fetch the from CTX->request) but as the Action class is becoming quite large, I suggest that we attach some kind of an Environment object to each Action instead. The suggested way to get information of your environment (request params, user, group, language etc) would be to use this environment object. By default this object could provide just hooks to CTX->request but would be completely customizable. What do you think about this? Should response or controller be handled through the environment also? If my Service Call shares code with a Handler which would do redirection, do we want this to affect the real response/require refactoring? Should Service calls be possible to be prohibited to alter main template params directly through controller? I'm sure that some of these issues could be circumvented using strict coding policies, like using Handlers and Handler Calls only as a wrappers which gather and pass all the relevant information to Service Calls, but this is not very intuitive and I'd rather make the Actions something which could be coded intuitively so that they can easily be reused for different types of calls. - Antti |