ATWF A Tcl Web Framwork

Check-in [4204f29af9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:small fixes

git-svn-id: https://atwf.svn.sourceforge.net/svnroot/atwf@614 3ddb7fe1-eb8e-4980-8f37-d9e37380b5db

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4204f29af9f5c227bada61f264f059af6ca9f504
User & Date: arnulf@wiedemann-pri.de 2010-12-05 16:54:01
Context
2010-12-05
18:43
fixes for application and added test_apptool directory

git-svn-id: https://atwf.svn.sourceforge.net/svnroot/atwf@615 3ddb7fe1-eb8e-4980-8f37-d9e37380b5db check-in: 8dd8c9b485 user: arnulf@wiedemann-pri.de tags: trunk

16:54
small fixes

git-svn-id: https://atwf.svn.sourceforge.net/svnroot/atwf@614 3ddb7fe1-eb8e-4980-8f37-d9e37380b5db check-in: 4204f29af9 user: arnulf@wiedemann-pri.de tags: trunk

2010-12-04
23:10
initial version

git-svn-id: https://atwf.svn.sourceforge.net/svnroot/atwf@613 3ddb7fe1-eb8e-4980-8f37-d9e37380b5db check-in: 23292c4f81 user: arnulf@wiedemann-pri.de tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to library/ATWF/Configs/Ini.tcl.

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  #
  # @param  array  config
  # @param  string key
  # @param  string value
  # @throws ConfigException
  # @return array
::itcl::body Configs::Ini::_processKey {config key value} {
    if {[regexp {([^@]*)@([^@]*)@(.*)$} $value -> prefix subst_var suffix]} {
        switch $subst_var {
	APPLICATION_PATH {
	    if {![::info exists ::env($subst_var)]} {
	        return -code error "missing environment variable \"$subst_var\""
	    }
	    set value "${prefix}$::env($subst_var)$suffix"
	  }







|







215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  #
  # @param  array  config
  # @param  string key
  # @param  string value
  # @throws ConfigException
  # @return array
::itcl::body Configs::Ini::_processKey {config key value} {
    while {[regexp {([^@]*)@([^@]*)@(.*)$} $value -> prefix subst_var suffix]} {
        switch $subst_var {
	APPLICATION_PATH {
	    if {![::info exists ::env($subst_var)]} {
	        return -code error "missing environment variable \"$subst_var\""
	    }
	    set value "${prefix}$::env($subst_var)$suffix"
	  }

Changes to library/ATWF/Controllers/Actions/Helpers/ViewRenderer.tcl.

789
790
791
792
793
794
795
796
797
798
799
800
801
802
803

804
805
806
807
808
809
810
811
}

  #============================ renderScript ===================================
  # Render a view script (optionally to a named response segment)
  #
  # Sets the noRender flag to true when called.
  #
  # @param  string $script
  # @param  string $name
  # @return void
::itcl::body Controllers::Actions::Helpers::ViewRenderer::renderScript {script {name {}}} {
    if {$name ne ""} {
        set name [getResponseSegment]
    }


    [getResponse] appendBody [$view render $script] $name

    setNoRender
}

  #============================ render =========================================
  # Render a view based on path specifications
  #







|
|






>
|







789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
}

  #============================ renderScript ===================================
  # Render a view script (optionally to a named response segment)
  #
  # Sets the noRender flag to true when called.
  #
  # @param string script
  # @param string name
  # @return void
::itcl::body Controllers::Actions::Helpers::ViewRenderer::renderScript {script {name {}}} {
    if {$name ne ""} {
        set name [getResponseSegment]
    }

    set content [$view render $script]
    [getResponse] appendBody $content $name

    setNoRender
}

  #============================ render =========================================
  # Render a view based on path specifications
  #

Changes to library/ATWF/Controllers/Plugins/Broker.tcl.

325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
  # @return void
::itcl::body Controllers::Plugins::Broker::postDispatch {request} {
    foreach key [lsort [dict keys $_plugins]] {
	set plugin [dict get $_plugins $key]
        try {
            $plugin postDispatch $request
        } trap error [list msg opts] {
puts "MSG![self class]:[self method]!$msg!$opts!"
#            if {[[::ATWF::Controllers::Front::getInstance] throwExceptions]} {
#                throw $e
#            } else {
#                [getResponse] setException $e
#            }
        }
    }







|







325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
  # @return void
::itcl::body Controllers::Plugins::Broker::postDispatch {request} {
    foreach key [lsort [dict keys $_plugins]] {
	set plugin [dict get $_plugins $key]
        try {
            $plugin postDispatch $request
        } trap error [list msg opts] {
puts stderr "MSG![self class]:[self method]!$msg!$opts!"
#            if {[[::ATWF::Controllers::Front::getInstance] throwExceptions]} {
#                throw $e
#            } else {
#                [getResponse] setException $e
#            }
        }
    }

Changes to library/ATWF/Controllers/Requests/Http.tcl.

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276

namespace eval ::ATWF {


::itcl::extendedclass Controllers::Requests::Http {
    inherit ::ATWF::Controllers::Requests::Request

# FIXME !!!! that are php gobal variables!!!
    public common _SERVER [list]
    public common _GET [list]
    public common _POST [list]
    public common _COOKIE [list]
    public common _ENV [list]

     # Allowed parameter sources
     # @variable dict
    protected variable _paramSources [dict create GET _GET POST _POST]

     # REQUEST_URI
     # @variable string
    protected variable _requestUri [list]
................................................................................
     # @variable string
    protected variable _basePath [list]

     # PATH_INFO
     # @variable string
    protected variable _pathInfo [list]

     # Instance parameters
     # @variable list
    protected variable _params [list]

     # Alias keys for request parameters
     # @variable list
    protected variable _aliases [list]

    constructor {{uri {}}} {}

    public method __get {key}
................................................................................
  #============================ setQuery =======================================
  # Set GET values
  #
  # @param  string|array $spec
  # @param  null|mixed $value
  # @return Controllers::Requests::Http
::itcl::body Controllers::Requests::Http::setQuery {spec {value {}}} {
    if {$value eq "" && [llength $spec] < 2} {
        return -code error "Invalid value passed to setQuery(); must be either list of values or key/value pair"
    }
    if {$value eq "" && [llength $spec] > 1} {
        foreach {key value} $spec {
            setQuery $key $value
        }
        return $this







<
<
<
<
<
<
<







 







<
<
<
<







 







|







26
27
28
29
30
31
32







33
34
35
36
37
38
39
..
46
47
48
49
50
51
52




53
54
55
56
57
58
59
...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265

namespace eval ::ATWF {


::itcl::extendedclass Controllers::Requests::Http {
    inherit ::ATWF::Controllers::Requests::Request








     # Allowed parameter sources
     # @variable dict
    protected variable _paramSources [dict create GET _GET POST _POST]

     # REQUEST_URI
     # @variable string
    protected variable _requestUri [list]
................................................................................
     # @variable string
    protected variable _basePath [list]

     # PATH_INFO
     # @variable string
    protected variable _pathInfo [list]





     # Alias keys for request parameters
     # @variable list
    protected variable _aliases [list]

    constructor {{uri {}}} {}

    public method __get {key}
................................................................................
  #============================ setQuery =======================================
  # Set GET values
  #
  # @param  string|array $spec
  # @param  null|mixed $value
  # @return Controllers::Requests::Http
::itcl::body Controllers::Requests::Http::setQuery {spec {value {}}} {
    if {($value eq "") && ([llength $spec] < 1)} {
        return -code error "Invalid value passed to setQuery(); must be either list of values or key/value pair"
    }
    if {$value eq "" && [llength $spec] > 1} {
        foreach {key value} $spec {
            setQuery $key $value
        }
        return $this

Changes to library/ATWF/Controllers/Requests/Request.tcl.

24
25
26
27
28
29
30







31
32
33
34
35
36
37
# @version     $Id$
#************************************************************************/

namespace eval ::ATWF {

::itcl::extendedclass Controllers::Requests::Request {
    inherit ::ATWF::Base








     # Has the action been dispatched?
     # @variable boolean
    protected variable _dispatched false

     # Module
     # @variable string







>
>
>
>
>
>
>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# @version     $Id$
#************************************************************************/

namespace eval ::ATWF {

::itcl::extendedclass Controllers::Requests::Request {
    inherit ::ATWF::Base

# FIXME !!!! that are php gobal variables!!!
    public common _SERVER [list]
    public common _GET [list]
    public common _POST [list]
    public common _COOKIE [list]
    public common _ENV [list]

     # Has the action been dispatched?
     # @variable boolean
    protected variable _dispatched false

     # Module
     # @variable string

Changes to library/ATWF/Controllers/Routers/Rewrite.tcl.

342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371

    # Find the matching route
    foreach {name route} $_routes {
        # TODO: Should be an interface method. Hack for 1.0 BC
        if {([$route info function isAbstract] ne "") && [$route isAbstract]} {
            continue
        }
        
        # TODO: Should be an interface method. Hack for 1.0 BC  
        if {([$route info function getVersion] ne "") || ([$route getVersion] == 1)} {
            set match [$request getPathInfo]
        } else {
            set match $request
        }
                    
	# for Tcl match should always be [$request getPathInfo] as getVersion returns 1
        if {[set params [$route match $match]] ne ""} {
            _setRequestParams $request $params
            set _currentRoute $name
            break
        }
    }

    return $request

}

  #============================ _SetRequestParams ==============================
::itcl::body Controllers::Routers::Rewrite::_setRequestParams {request params} {
    foreach {param value} $params {







<
<
<
|
<
<
<
<
<






<







342
343
344
345
346
347
348



349





350
351
352
353
354
355

356
357
358
359
360
361
362

    # Find the matching route
    foreach {name route} $_routes {
        # TODO: Should be an interface method. Hack for 1.0 BC
        if {([$route info function isAbstract] ne "") && [$route isAbstract]} {
            continue
        }



        set match [$request getPathInfo]





        if {[set params [$route match $match]] ne ""} {
            _setRequestParams $request $params
            set _currentRoute $name
            break
        }
    }

    return $request

}

  #============================ _SetRequestParams ==============================
::itcl::body Controllers::Routers::Rewrite::_setRequestParams {request params} {
    foreach {param value} $params {

Changes to library/ATWF/Layout.tcl.

753
754
755
756
757
758
759

760
761
762
763
764
            $view setScriptPath $path
        }
    } else {
        if {([set path [getViewBasePath]] ne "")} {
            $view addBasePath $path $_viewBasePrefix
        }
    }


    return [$view render $name]
}

} ; # END ::ATWF







>





753
754
755
756
757
758
759
760
761
762
763
764
765
            $view setScriptPath $path
        }
    } else {
        if {([set path [getViewBasePath]] ne "")} {
            $view addBasePath $path $_viewBasePrefix
        }
    }
    $view VarSet container $_container

    return [$view render $name]
}

} ; # END ::ATWF