[Xotcl] gdbm/sdbm/textfile database trouble

Walter Augustin matto at matto.at
Thu Jun 16 13:42:35 CEST 2005


Hi!

I am quite new to [XO]Tcl and currently working on some scripts for Prof.
Neumann's OO programming class.
I run my scripts under Windows which has been working well so far - until I
tried to run the "Cached WebPage" which depends upon one out of three
offered storage resources.

In the slides, Prof. Neumann offers to use TextFile, Gdbm and Sdbm:

	package require xotcl::store::textfile; set DBClass Storage=TextFile
	#package require xotcl::store::gdbm; set DBClass Storage=Gdbm
	#package require xotcl::store::sdbm; set DBClass Storage=Sdbm

In the "Cache" class this should be used like this:

Class Cache
Cache instproc init {} {
  Storage=TextFile [self]::db ;# Erzeuge DB als Unterobjekt
  [self]::db open [self]  ;# öffne DB mit aktuellen Namen des Objekts
  next
}

Now I tried all three possibilities, uncommenting lines and changing the
"Storage=Textfile|Gdbm|Sdbm" part of the script. The results leave me in
confusion, since the errors seem to be all different:

[TextFile:]
C:\Programme\tcl\scripts\stock>tclsh stock.xotcl
couldn't open "::cache": no such file or directory
    while executing
"::open $filename a+"
    (procedure "set" line 21)
    ::cache::db ::Storage=TextFile->set
    invoked from within
"[self]::db set $url [list date $date content $page]"
    (procedure "store" line 4)
    ::cache ::Cache->store
    invoked from within
"cache store $url $content"
    (procedure "loadPage" line 15)
    ::s1 ::CachedWebPage->loadPage
    invoked from within
"my loadPage "
    (procedure "getContent" line 3)
    ::s1 ::WebPage->getContent
    invoked from within
"my getContent"
    (procedure "getRate" line 4)
    ::s1 ::StockInfo->getRate
    invoked from within
"s1 getRate"
    (file "stock.xotcl" line 116)

[Gdbm:]
C:\Programme\tcl\scripts\stock>tclsh stock.xotcl
can't find package xotcl::store::gdbm
    while executing
"package require xotcl::store::gdbm"
    (file "includes.inc" line 4)
    invoked from within
"source includes.inc"
    (file "stock.xotcl" line 1)

(-> Okay, the package is missing at all. I could make Stefan Vogel's Tcl
wrapper port work - although the installation package was missing the
pkgIndex.tcl file which he mailed me separately, but the XOTcl extension
seems just not to be available under Windows. So, next I tried:)

[Sdbm:]
C:\Programme\tcl\scripts\stock>tclsh stock.xotcl
Open on '::cache::db' failed with '::cache'.
    ::cache::db ::Storage=Sdbm->open
    invoked from within
"[self]::db open [self]  "
    (procedure "init" line 4)
    ::cache ::Cache->init
    ::Cache ::xotcl::Class->create
    ::Cache ::xotcl::Class->unknown
    invoked from within
"Cache cache     "
    (file "stock.xotcl" line 87)

Source code is from Prof. Neumann:
http://nm.wu-wien.ac.at/Lehre/oo2/stockinfo.xotcl
I just commented out the package require Gdbm part and placed the three
variants (see above) in the head of the script ("includes.inc" script).
Plus, I replaced "Gdbm" in the Cache::init method by "TextFile" or "Sdbm" as
appropriate.

Sorry this got lengthy ... I wonder if any of you ran into this once and has
a hint for me. I'm stuck :( And sorry, I am a beginner, maybe I miss
something obvious.

Thanks in advance!

Walter




More information about the Xotcl mailing list