Balamurugan-R / wub

Automatically exported from code.google.com/p/wub
0 stars 0 forks source link

Direct domain with objects does not work solution attached #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. svn version 2083 checked out 11/21/2009
2. any Direct object example from examples package run ex9 for instance. 
3. cd into ex9 directory 
4. on command line start wub "/opt/usr8.6b.1/bin/tclsh8.6 ex.tcl
5. on browser goto url http://localhost:<port>/directoo/

What is the expected output? What do you see instead?
expect to see : (note html extracted)

Default function for MyOODomain

    * /default
    * /test

Instead I see errorinfo : 

Can't find method /default in any class of Direct::"

What version of the product are you using? On what operating system?
svn version 2083 checked out 11/21/2009
Linux Fedora 9 

Please provide any additional information below.
I fixed the problem by modifying Direct.tcl see output of svn diff below
Behavior at least from presentation on wub given at the 2009 European
Tcl/Tk conference is to map / to /default so wild card was wrong ( see
first diff); It could be that the example is wrong in this case and the
method /default should be changed to / ? Another problem was that the
search for methods to invoke in the object was seaching [self] and not
$object so all the methods of self in this case Direct:: were being
searched this lead to the error. 
Index: Direct.tcl
===================================================================
--- Direct.tcl  (revision 2083)
+++ Direct.tcl  (working copy)
@@ -145,7 +145,7 @@
     # locate a matching direct method in an object
     method do_obj {rsp} {
    Debug.direct {do direct $object $mount $ctype}
-   
+
    # search for a matching command prefix
    set fn [dict get $rsp -suffix]
    set cprefix [file split [armour $fn]]
@@ -273,13 +273,13 @@
     constructor {args} {
    set ctype "x-text/html-fragment"
    set mount "/"
-   set wildcard /
+   set wildcard /default

    foreach {n v} $args {
        set [string trimleft $n -] $v
        Debug.direct {variable: $n $v}
    }
-
+   
    # one or the other of namespace or object must exist
    if {![info exist namespace] && ![info exists object]} {
        # no namespace or object - must be a mixin
@@ -316,7 +316,7 @@
        set mixins [info class mixins $class]
        foreach m [lreverse [lsort -dictionary [info class methods $class
-private -all]]] {
        if {[string match /* $m]} {
-           foreach class [list [info object class [self]] {*}$mixins] {
+           foreach class [list [info object class $object ]  {*}$mixins] {
            if {![set unfound [catch {
                lindex [info class definition $class $m] 0
            } def eo]]} {

Original issue reported on code.google.com by cwjo...@gmail.com on 7 Dec 2009 at 1:11

Attachments:

GoogleCodeExporter commented 8 years ago
Regarding /default ... you can pass in a wildcard argument to the object 
constructor,
it will determine the method/proc sought for wildcard request handling.

Original comment by mcc...@gmail.com on 4 Feb 2010 at 11:23

GoogleCodeExporter commented 8 years ago
Your observation, regarding the choice of which class to search for matching 
methods,
seems right.  I'm adopting it.

Original comment by mcc...@gmail.com on 4 Feb 2010 at 11:28

GoogleCodeExporter commented 8 years ago

Original comment by mcc...@gmail.com on 4 Feb 2010 at 11:29