On 2005.02.06, Dan Chak <[EMAIL PROTECTED]> wrote:
> How can I get all my code to use my proc, and the faking-of-cloning
> process to use the real proc?

That was the first example I gave that only registered the [ns_ictl
oncreate] script, without [eval]'ing it in the master interp.  e.g.:

    set script {
        rename proc _proc
        _proc proc {proc_name args} {
           set proc_namespace [uplevel {::namespace current}]
           if { $proc_namespace != "::" } {
              regsub {^::} $proc_namespace {} proc_namespace
              set proc_name "${proc_namespace}::${proc_name}"
           }

           ns_log notice "PROC: $proc_name"
           set procdef [list _proc $proc_name]
           eval [concat $procdef $args]
       }
    }

    ns_ictl oncreate $script


Also, why does your version of [proc] change its signature?  The
standard signature of [proc] is {name args body} -- if you use the same
signature, you could eliminate that [eval [concat]] weirdness:

    set script {
        rename proc _proc
        _proc proc {name args body} {
           ns_log notice "PROC: $name"
           _proc $name $args $body
       }
    }

I'm also puzzled by your little namespace "::" stripper thingy.  My
understanding of the code is, "if the caller isn't in the root
namespace, define the proc relative to the namespace it's in regardless
of if the proc was defined with an absolute namespace (i.e. the leading
"::")?"  You do realize that will break existing Tcl code that uses
namespaces, right?  You are doing this for some good, but mostly
unguessable reason which is unknown to me, right?

> It would be great if there was a 'ns_ictl aftercreate' command so the
> tcl-defined [proc] can be used for the cloning and the user-defined
> proc gets used for everything else.  Any ideas on how to fake this?

    set script [ns_ictl get]
    append script \n {your aftercreate script here}
    ns_ictl save $script

> Also, I'm using AOLServer 4.0.9 with Tcl 8.4.9, though I would hope the
> solution would not vary vastly from one version set to the next.

It shouldn't, but it could.  It's just good to document (and, I consider
this mailing list's archives a kind of documentation) what version was
used at the time, so others don't have to wonder and/or ask.


-- Dossy

--
Dossy Shiobara                       mail: [EMAIL PROTECTED]
Panoptic Computer Network             web: http://www.panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)


--
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