From: Gustaf N. <ne...@wu...> - 2005-12-31 00:15:21
|
Zoran Vasiljevic wrote: > > Am 30.12.2005 um 19:19 schrieb Gustaf Neumann: > >> >> how will be the call, when >> >> ns_register_filter preauth GET /junk myfilter >> >> is registered? when >> >> myfilter preauth > > Like this. fine. > >> >> is called, this would be pretty much comaptible with the aolserver >> for the simple cases. >> this would as well work with xotcl methods in this case. however, >> this would as well be >> the case, when WHY is placed before the passed arguments. >> >> the hyperflexible approach would be to use >> >> ns_register_filter preauth GET /junk [list myfilter arg1] arg2 arg3 > > I do not understan why bother with all this arguments (arg2 arg3, etc) > when you can easily construct the script using the [list] command? ... > and if you need to pass arguments to "myfilter" just use > ns_register_filter preauth GET /junk [list myfilter $arg1 $arg2 $arg3] > Would this be less flexible? I think not. Flexible, well... Here is a reason: look at the example from my first mail. with xotcl (or other oo approaches) it is the most straightforward to implement the filters as methods. Class Filter Filter instproc preauth args { .... } Filter instproc postauth args { .... } Filter myfilter In such cases it is most conveniant, when the WHY argument is first, without loosing the ability to pass to the handlers. When appending always the WHY at the end, the arguments become the "methods", unless one has a zero-argument filter proc. When one needs an additional argument, one has to change the way to map he methods. i would be as happy with ns_register_filter preauth GET /junk [list myfilter $arg1 $arg2 $arg3] calling myfilter WHY arg1 arg2 arg3 Certainly, in pure tcl cases, it does not matter much, where the WHY is placed. When the WHY is always appended to the end - as you suggests - i envision myself defining the filter like ns_register_filter preauth GET /junk [list myfilter preauth $arg1 $arg2 $arg3] ns_register_filter postauth GET /junk [list myfilter postauth $arg1 $arg2 $arg3] and not much caring about the WHY argument. certainly doable, but slightly strange. as i said before, the most common case it that the filter cmd is used without arguments. for the other cases, there is always a way to hack around. decide, whatever you prefer. all the best -gustaf |