2019-01-10

Apache Rivet 3.1.1 released

下面是 Apache Rivet 3.1.1 主要的更新

  • Rivet 3.1.1 attempts to solve various problems with the CMake scripts needed to build mod_rivet on Windows
  • Several broken links in the manual were fixed

主要修正了在 Windows 平台使用 CMake 編譯的問題。

2019-01-04

Magicsplat Tcl/Tk for Windows 1.9.0

Magicsplat Tcl/Tk for Windows


Updated packages: Tcl 8.6.9, Tk 8.6.9, TDBC 1.1, sqlite 3.26.0, thread 2.8.4, Itcl 4.1.2, tclcsv 2.3, twapi 4.3.5, promise 1.1, BWidget 1.9.13, tklib 2019-01-01, CAWT 2.4.3, TclCurl 7.63.0, DiffUtil 0.4.1, TclWS 2.6.2.

所以 Magicsplat Tcl/Tk for Windows 也更新到 Tcl/Tk 8.6.9。

2019-01-02

BAWT 0.9.0

BAWT 釋出了 0.9.0,將 Tcl/Tk 的版本更新到 8.6.9,同時也更新了一些 Tcl 套件(例如 tDOM, tcl3d)。可以看 Release History 更新的部份。

所以我也安裝這個版本進行測試。

PS. BAWT 也提供了 Visual C++ 連結的部份,但是根據在 0.8.0 測試的結果,一樣可能會遇到不同的 Visual C++ 版本的相容性問題("fatal error C1047" issue),不過如果是同版本應該就可以正確連結。

2019-01-01

promise 1.1.0

ANNOUNCE: promise 1.1.0 released
tcl-promise-spec


Promises are concurrency primitives that let you write asynchronous code in a sequential style. This Tcl based implementation is mostly modeled on the Javascript/ECMAScript 7 standard. 

因為作者釋出新版,所以我也更新了我自己的 openSUSE RPM spec.

2018-12-17

VecTcl: 0.3

VecTcl v0.3:
This is a checkpoint release. Bugfixes since 0.2 are included.


VecTcl 在最近釋出了 v0.3 版,所以我更新了我自己的 openSUSE RPM spec 以進行測試。

2018-12-08

Apache Rivet and DIO

Apache Rivet 提供了 DIO 套件存取資料庫。而 DIO::Postgresql 是以 Pgtcl 作為底層的套件。

我先在 PostgreSQL 建立一個表格 Notes 作為測試:
create table if not exists Notes (id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid, 
title varchar(255), body text, created timestamp, PRIMARY KEY (id));


接下來撰寫一個簡單的程式測試 Apache Rivet。

建立檔案 tdbcnoteservices.tcl,將資料庫的實作部份放在這裡(使用 tdbc::postgres):
package require tdbc::postgres

proc getAllNotes {} {
    set rows {}

    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {select * from Notes order by created}]
    $stmt execute
    set rows [$stmt allrows -as lists]

    $stmt close
    db close

    return $rows
}

proc getNote {id} {
    set myparams [dict create id $id]

    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {select * from Notes where id = :id}]
    $stmt execute $myparams
    set rows [$stmt allrows -as lists]
   
    $stmt close
    db close

    return $rows    
}

proc addNote {title body} {
    set myparams [dict create title $title body $body]
    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {INSERT INTO Notes (Title, Body, Created) values (:title, :body, now())}]
    set resultset [$stmt execute $myparams]
    set rowcount [$resultset rowcount]

    $resultset close
    $stmt close
    db close

    return $rowcount
}

proc updateNote {id title body} {
    set myparams [dict create id $id title $title body $body]
    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {UPDATE Notes SET Title = :title, Body = :body where Id = :id}]
    set resultset [$stmt execute $myparams]
    set rowcount [$resultset rowcount]

    $resultset close
    $stmt close
    db close

    return $rowcount
}

proc deleteNote {id} {
    set myparams [dict create id $id]
    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {DELETE FROM Notes where Id = :id}]
    set resultset [$stmt execute $myparams]
    set rowcount [$resultset rowcount]

    $resultset close
    $stmt close
    db close

    return $rowcount
}


再來就是測試我比較不熟悉的 DIO 套件,建立 dionoteservices.tcl 檔案,然後實作同樣的功能:
package require DIO

proc getAllNotes {} {
    set rows {}
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set rows [list]
    $db forall {select id, title, body, created from Notes order by created} row {
        set myrow [list $row(id) $row(title) $row(body) $row(created)]    
        lappend rows $myrow
    }

    $db destroy
    return $rows
}

proc getNote {id} {
    set rows {}    
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set query "select id, title, body, created from Notes where id = '$id'"
    set rows [list]
    $db forall $query row {
        set myrow [list $row(id) $row(title) $row(body) $row(created)]
        lappend rows $myrow
    }

    $db destroy
    return $rows    
}

proc addNote {title body} {
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set arrayVar(Title) $title
    set arrayVar(Body) $body
    set arrayVar(Created) "now()"
    set rowcount [$db insert Notes arrayVar]

    $db destroy
    return $rowcount
}

proc updateNote {id title body} {
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set arrayVar(Id) $id
    set arrayVar(Title) $title
    set arrayVar(Body) $body
    set rowcount [$db update arrayVar -table Notes -keyfield Id]

    $db destroy
    return $rowcount
}

proc deleteNote {id} {
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set rowcount [$db delete $id -table Notes -keyfield Id]

    $db destroy    
    return $rowcount
}


這樣只要 source 的檔案不同,就可以測試不同的資料庫實作部份。

2018-12-07

tclws 2.6.2

ANNOUNCE: tclws 2.6.2 released


Web Services for Tcl provides both client side access to Web Services and server side creation of Web Services. Currently only document/literal and rpc/encoded with HTTP Soap transport are supported on the client side.

tclws 這次只有 client 端的修正。我也更新了我自己的 openSUSE RPM spec

2018-12-06

Tcl: argv

argv

$argv is a global variable provided by tclsh and wish mainline code.


下面就是 Tcler's wiki 的範例(我只有改寫第一行):
#!/usr/bin/env tclsh

if { $::argc > 0 } {
    set i 1
    foreach arg $::argv {
        puts "argument $i is $arg"
        incr i
    }
} else {
    puts "no command line argument passed"
}

2018-11-29

HTTP/3 explained

HTTP/3 explained
HTTP/3 協定出爐
The Road to QUIC
HTTP/3


可以開始閱讀 HTTP/3 相關的文件。

From https://http3-explained.haxx.se/images/quic-stack.png

HTTP/3 主要在 UDP 上建立一個新的協定,QUIC (Transfer protocol over UDP)。

Apache Rivet 3.1.0 released

Apache Rivet 3.1.0 released


Apache Rivet is a module providing Tcl scripting capability with the Apache HTTP Web Server. With Apache Rivet you can run pure Tcl scripts or parse Rivet templates. Rivet templates allow Tcl code to be embedded in HTML pages, in pretty the same way you can do with PHP. Rivet extends Tcl with several commands providing functionalities needed to control script execution within the Apache web server or other tasks common to the web programming. Rivet comes with a library of Tcl packages providing session management, HTML form output and validation, DBMS abstraction and more
 


Release Notes:

Rivet 3.1.0 is a bug fix release of Rivet 3.0.3. The decision of releasing a new point release has been suggested by the nature of the fix that, even though unlikely, in principle might break existing code developed on wrong assumptions about the behavior of commands ::rivet::var_ps and ::rivet::var_post


Web site: http://tcl.apache.org/
Distribution: http://www.apache.org/dyn/closer.lua/tcl/rivet