From: Chris W. <ch...@cw...> - 2005-07-04 14:47:33
|
On Jul 2, 2005, at 5:49 PM, Antti M V=E4h=E4kotam=E4ki wrote: > Thought about this some more. I think it is a good idea to reserve =20 > an accessor (or a parameter) in the action for the array of all =20 > additional parts since it defines the action much like action's =20 > name or it's task. You never know when it is needed ;) That's probably a good idea. I moved the code to assign these from =20 the request into a separate subroutine as well, so you can do: # assign the additional parameters from the Request object $action->url_additional_param_from_request; my @values =3D url_additional_param; BTW, is there a better name for these things? Calling everything =20 'url_additional' is very klunky and not terribly descriptive. > Also it would be nice to add the rest of the additional parts, =20 > which were not mapped to a param, to a separate param. > > So if your url would be: > /filearea/download/users/madonna/music/garbage.mp3 > > and your action.ini would have: > [filearea url_additional] > download =3D area_type > download =3D area_id > > The you would end with an action such that: > $action->additional -> [ 'users', 'madonna', 'music', 'garbage.mp3' ] > $action->param('area_type') -> 'users' > $action->param('area_id') -> 'madonna' > $action->param('other_additional') -> [ 'music', 'garbage.mp3' ] > > What do you think? It's not a bad idea. (That Action class just keeps growing... :-) > Also in Dicole we have a $action->derive_url -function which tries =20 > to take the current action's url and modify it a bit: > $action->derive_url( task =3D> 'view') =3D> /filearea/view/users/=20 > madonna/music/garbage.mp3 > > You might want concider something similiar for OI2 - it has been =20 > quite handy for our use since we also usually have an additional id =20= > in the url specifying target user or group and it hardly ever =20 > changes. We haven't yet modified it to use url_additional settings =20 > so that it would be possible to override also those in a similiar =20 > fashion, but I think it will be done at some point like this: > $action->derive_url( area_id =3D> 'bjork', other_additional =3D> =20 > [ 'robots.txt'] ) -> /filearea/download/users/bjork/robots.txt I think a lot of the functionality in OpenInteract2::URL does this. =20 For instance, to replicate the above you'd do: $action->create_url({ TASK =3D> 'view', URL_PARAMS =3D> [ 'users', =20= 'madonna', ... ] ); Creating a shortcut to fill the URL_PARAMS with default values, or to =20= be smarter to associate some additional parameters with named values =20 (like your 'area_id' above) seems application-specific, and may be =20 more appropriate a base Action class in your app. Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |