FWIW, I hate having a bunch of separate TCL routines to do related
things.  IMO, one of the nice things about TCL is that knowing you
want to do a file thing makes it reasonable to look at [file] first,
not [openfile], [rewindfile], [truncatefile], ...  Separate routines
makes it harder to find out "how do I do this thing?", even if I know
how to do something related (like, if I know [ns_conn peeraddr] gives
me the remote IP, it would be reasonable to guess that [ns_conn] might
also have a way to give me the client address).

Overloading ns_conn is easy in TCL:

proc rl_conn {arg {conn ""}} {
  global __form __url

  if {[info exists __url]} {
    if {$arg == "url"} {
      return $__url
    } elseif {$arg == "urlc"} {
      return [llength [split [string range $__url 1 end] /]]
    } elseif {$arg == "urlv"} {
# NOTE: might need to trim trailing slashes here??
      return [split [string range $__url 1 end] /]
    }
  }
  if {$arg == "form"} {
    if {[info exists __form]} {
      return $__form
    }
  }
  return [aol_ns_conn $arg]
}

# NOTE: next rename fails when file is sourced, 2nd rename fails
# on boot; this is correct
catch {rename ns_conn aol_ns_conn}
catch {rename ns_conn {}}
rename rl_conn ns_conn

Jim





>
> +---------- On Jul 19, Nathan Folkman said:
> > Actually I think Dossy is proposing to add a new arg to the ns_conn
> > command, and not changing the current behavior of "ns_conn peeraddr" in
> > order to keep backwards compatibility. I believe the proposal was to add
> > something like "ns_conn clientaddr". Dossy, please correct me if I'm wrong.
>
> A totally separate command, like "ns_clientaddr", would be better. It's
> easy to backport a standalone command - particularly when it can be
> easily implemented in Tcl alone. It's more involved to backport a new
> ns_conn subcommand.
>
>
> --
> AOLserver - http://www.aolserver.com/
>
> To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with 
> the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field 
> of your email blank.
>


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to