clsql-demo

43 views
Skip to first unread message

fendres

unread,
Jun 25, 2010, 7:38:20 AM6/25/10
to weblocks
Hi all,
I am trying to get started with weblocks (and lisp, emacs-slime all at
once). I got the demo and the simple blog to work. To be able to
(require ...) the latter I had to create a link in clbuild/systems to
clbuild/source/weblocks/examples/simple-blog/simple-blog.asd.
This procedure did not work for the clsql demo. I get the following
error:

(require 'weblocks-clsql-demo)
failed to find the TRUENAME of /home/lakritze/endres/clbuild/systems/
weblocks-clsql-demo.lisp:
No such file or directory
[Condition of type SB-INT:SIMPLE-FILE-ERROR]

I do not know how useful the Backtrace is, just to make sure:

Backtrace:
0: (SB-IMPL::SIMPLE-FILE-PERROR "failed to find the TRUENAME of ~A"
#P"/home/lakritze/endres/clbuild/systems/weblocks-clsql-demo.lisp" 2)
1: ((FLET SB-IMPL::FAIL) "failed to find the TRUENAME of ~A" #P"/
home/lakritze/endres/clbuild/systems/weblocks-clsql-demo.lisp" 2)
2: (SB-IMPL::QUERY-FILE-SYSTEM #P"/home/lakritze/endres/clbuild/
systems/weblocks-clsql-demo.lisp" :TRUENAME T)
3: (TRUENAME #P"/home/lakritze/endres/clbuild/systems/weblocks-clsql-
demo.lisp")
4: ((FLET SB-C::TRY-WITH-TYPE) #P"/home/lakritze/endres/clbuild/
systems/weblocks-clsql-demo.lisp" "lisp" T)
5: (SB-C::VERIFY-SOURCE-FILE #P"/home/lakritze/endres/clbuild/
systems/weblocks-clsql-demo.lisp")
6: (SB-C::VERIFY-SOURCE-FILE #P"/home/lakritze/endres/clbuild/
systems/weblocks-clsql-demo.lisp")[:EXTERNAL]
7: (COMPILE-FILE #P"/home/lakritze/endres/clbuild/systems/weblocks-
clsql-demo.lisp")[:EXTERNAL]
8: ((SB-PCL::FAST-METHOD ASDF:PERFORM (ASDF:COMPILE-OP ASDF:CL-
SOURCE-FILE)) ..)
9: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0.
SB-PCL::.ARG1.)) ..)
10: ((SB-PCL::FAST-METHOD ASDF:PERFORM :AROUND (ASDF:OPERATION
ASDF:CL-SOURCE-FILE)) ..)
11: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND (ASDF:COMPILE-OP
ASDF:CL-SOURCE-FILE)) ..)
12: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND (ASDF:COMPILE-OP
ASDF:CL-SOURCE-FILE)) ..)
13: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND (ASDF:COMPILE-OP
ASDF:CL-SOURCE-FILE)) ..)
14: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND (ASDF:COMPILE-OP
ASDF:CL-SOURCE-FILE)) ..)
15: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND (ASDF:COMPILE-OP
ASDF:CL-SOURCE-FILE)) ..)
16: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND (ASDF:COMPILE-OP
ASDF:CL-SOURCE-FILE)) ..)
17: ((LAMBDA ()))
18: ((FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK))
19: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-RECURSIVE-LOCK]291))

The file is not in that location but in the clbuild/source tree. I
compared the asd files of simple-blog and ...clsql-demo and do not
find any significant difference. I am using SBCL and emacs-slime. I
googled for the truename error message, but didn't find anything
related. Maybe this is more a symptom than a cause?

Does anybody know what I am doing wrong? My understanding of asdf is
quite limited.

Regards,
Felix

fendres

unread,
Jun 25, 2010, 8:32:29 AM6/25/10
to weblocks
Ok, found a solution to this one: restart slime. I first copied the
file instead of symbolic linking it. Tried, failed, made it a link,
but didn't restart slime.

New Problem:
The readme of the clsql-demo:
1. Go into conf/stores.lisp and configure the CLSQL store to point to
your database.
2. Load WEBLOCKS-CLSQL-DEMO into the Lisp environment.
3. Run (START-WEBLOCKS) command.
4. Create appropriate tables in the database by evaluating the
following expressions:
(clsql-sys:create-view-from-class 'employee)
(clsql-sys:create-view-from-class 'company)
(clsql-sys:create-view-from-class 'address)

These expressions from 4 fail:
There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION CLSQL-SYS:DATABASE-TYPE (3)>
when called with arguments
(NIL).
[Condition of type SIMPLE-ERROR]

I understand, that it resolves 'employee to NIL,
but I have no more ideas how to change that.

I configured the database, loaded the demo with
(require 'WEBLOCKS-CLSQL-DEMO) and start
with (weblocks:start-weblocks).
I also tried
(asdf:operate 'asdf:load-op 'weblocks-clsql-demo)
and
(in-package :weblocks-clsql-demo)
and I tried to prepend the package in the command:
(clsql-sys:create-view-from-class 'weblocks-clsql-demo:employee)

Any ideas? I guess it is an easy problem for someone
with more knowledge about lisp. For me it's a roadblock.

In the browser I get a poem about steve russel and
an error message on the "next" page: "An error has occured."
This is probably because of the missing tables...

Regards,
Felix

On Jun 25, 1:38 pm, fendres <198...@web.de> wrote:
> Hi all,
> I am trying to get started with weblocks (and lisp, emacs-slime all at
> once). I got the demo and the simple blog to work. To be able to
> (require ...) the latter I had to create a link in clbuild/systems to
> clbuild/source/weblocks/examples/simple-blog/simple-blog.asd.
> This procedure did not work for the clsql demo. I get the following
> error:
>
> (require 'weblocks-clsql-demo)
> failed to find the TRUENAME of /home/lakritze/endres/clbuild/systems/
> weblocks-clsql-demo.lisp:
>   No such file or directory
>    [Condition of type SB-INT:SIMPLE-FILE-ERROR]
>
> I do not know how useful the Backtrace is, just to make sure:
>
(...)

Nandan Bagchee

unread,
Jun 25, 2010, 12:19:31 PM6/25/10
to webl...@googlegroups.com
I am going to assume that it's because the class employee is not defined. Can you (using C-c C-c) ensure that the defclass is evaluated before running the create-view-from-class forms?
 
I will have to install weblocks-dev before I can be of any help.

Please also let us know where you installed weblocks from, and how you obtained the dependencies (clbuild?).

Does anyone recall if the clsql demo had some updates recently?

> The file is not in that location but in the clbuild/source tree. I
> compared the asd files of simple-blog and ...clsql-demo and do not
> find any significant difference. I am using SBCL and emacs-slime. I
> googled for the truename error message, but didn't find anything
> related. Maybe this is more a symptom than a cause? 

AFAIK the truename error is always because the actual file was not found on disk. 

Generally for asdf, there is a directory called systems which has symbolic links to asd files. The asd files actually reside in the source directory of the package (eg clbuild/source/closer-mop).

The only reason this is done is so that instead of adding hundreds of source directories containing asd files to asdf:*central-registry* one just needs to add a single directory containing the symlinks.

fendres

unread,
Jul 1, 2010, 5:49:40 PM7/1/10
to weblocks
On 25 Jun., 18:19, Nandan Bagchee <nandan.bagc...@gmail.com> wrote:
> I am going to assume that it's because the class employee is not defined. Can
> you (using C-c C-c) ensure that the defclass is evaluated before running the
> create-view-from-class forms?

Sorry that it took me so long to answer, I've been abroad.
You are right, if I evaluate employee it is not defined, and
the call to create-view-from-class gives the same exception
when called with NIL. However, C-c C-c or M-C-x in the
employee.lisp file (containing the clsql:def-view-class form)
does not change this. Should there be a defclass? I couldn't
find one in the directory tree of the clsql demo.

> Please also let us know where you installed weblocks from, and how you
> obtained the dependencies (clbuild?).
>
I am using clbuild. The procedure I used to install everything
in Ubuntu 9.10 is roughly as below.
Thanks for your help,
Felix

#Install procedure:
sudo aptitude install xemacs slime sbcl
sudo aptitude install darcs curl git-core mercurial -R
darcs get http://common-lisp.net/project/clbuild/clbuild
cd clbuild/
darcs gzcrcs --check
darcs gzcrcs --repair
chmod u+x clbuild
./clbuild check
./clbuild install weblocks cl-prevalence
./clbuild install trivial-backtrace
#set asd-file links for the weblock demos

#CLSQL-Fluid patch:
pushd ./source/clsql/
git remote add s11 git://repo.or.cz/clsql/s11.git
git fetch s11
git checkout -b fluid-pools s11/fluid-pools
popd
cd ./systems/
ln -s ../source/clsql/clsql-fluid.asd

Nandan Bagchee

unread,
Jul 1, 2010, 9:46:09 PM7/1/10
to webl...@googlegroups.com
> you (using C-c C-c) ensure that the defclass is evaluated before running the
> create-view-from-class forms?

Sorry that it took me so long to answer, I've been abroad.
You are right, if I evaluate employee it is not defined, and
the call to create-view-from-class gives the same exception
when called with NIL. However, C-c C-c or M-C-x in the
employee.lisp file (containing the clsql:def-view-class form)
does not change this. Should there be a defclass? I couldn't
find one in the directory tree of the clsql demo.


I have no idea what def-view-class is .. I presume under the covers it calls defclass?

Maybe someone who uses cl-sql can step in.

-- nandan

 

nunb

unread,
Jul 1, 2010, 10:07:38 PM7/1/10
to weblocks
The short version is you haven't connected to a database[0], and
that's what causing the problems.

[0] ie on-disk db, eval'ing (connected-databases) give you nil

Ok, this is what I did.

Start lisp, asdf load clsql, inspect (M-.) def-view-class (which is a
macro around defclass).

Evaluate the file clsql-tutorial.lisp file (from clsql/examples).

At the repl evaluate:

(in-package 'clsql-user)
(make-instance 'employee)

Inspect that (C-c C-v i) -- looks fine.

Evaluate:

CLSQL-USER> (create-view-from-class 'employee)

See error:

There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION DATABASE-TYPE (1)>
when called with arguments
(NIL).
[Condition of type SIMPLE-ERROR]

Somewhere in the clsql docs it says that before running the tutorial
one has to set up the database. Since I did not do that, and since M-.
on create-view-from-class indicates a *default-database* parameter
which is not set, I am going to say that's your problem.

nunb

unread,
Jul 1, 2010, 10:36:29 PM7/1/10
to weblocks
The clsql.pdf doc file lists connection strings in an appendix.

The simplest db to start with is probably sqlite (apt-get sqlite3)

In package clsql-user evaluate

(asdf:operate 'asdf:load-op 'clsql-sqlite3)

Then at a shell use `sqlite /tmp/ex.db` and use .exit to quit.

Check that it exists: `ls /tmp/*.db`

At repl: (connect '("/tmp/ex.db") :database-type :sqlite3)

This will set *default-database* so check its value.

All this is from clsql.pdf -- which has instructions for the other db
types too, if you need to use something else.

At this point the def-view-from-class should work fine.

Post any further developments.

fendres

unread,
Jul 7, 2010, 6:00:17 PM7/7/10
to weblocks
Ok, thanks. You seem to be right, but I got stuck halfway
unfortunately. One problem I have is understanding the
workings of slime, swank and sbcl. If I eval something
within an emacs buffer by M-C-x, where does that happen?
It doesn't influence the environment started with M-x slime,
right? I got confused about this. So the repl and the
evaluations are two separate things, I guess...
However I am not sure where the mentioned (C-c C-v i) should
go for instance. Sorry if I am slow, but I don't really grasp it
yet :-(.

I managed to to connect to my mysql database by executing
the clsql-tutorial.lisp file (from clsql/examples) with (load
#p"...").
However I during file evaluation I get an error after the connection
is established:
The value 0
is not of type
(OR (VECTOR CHARACTER) (VECTOR NIL) BASE-STRING SYMBOL
CHARACTER).
[Condition of type TYPE-ERROR]

Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread"
RUNNING {AE730F9}>)

Backtrace:
0: (STRING-EQUAL "YES" 0)[:EXTERNAL]
1: ((SB-PCL::FAST-METHOD CLSQL-SYS::OUTPUT-SQL (CLSQL-SYS::SQL-
CREATE-TABLE T)) #<error printing object>)
2: (CLSQL-SYS::SQL-OUTPUT #<error printing object>)
3: ((SB-PCL::FAST-METHOD EXECUTE-COMMAND (CLSQL-SYS::%SQL-
EXPRESSION)) #<error printing object>)[:EXTERNAL]
4: ((SB-PCL::FAST-METHOD CLSQL-SYS::%INSTALL-CLASS (CLSQL-
SYS::STANDARD-DB-CLASS T)) ..)[:EXTERNAL]
5: (CREATE-VIEW-FROM-CLASS EMPLOYEE)[:EXTERNAL]
(...)
I have no idea where to find that in the code. How can I relate
the error to the content of the source file? I checked the sbcl
debugger docs, but couldn't find anything. Since number 5
mentions create-view-from-class, I inspected it with the
(M-.) you tought me, but it didn't show me anything I could
relate to the error.

Could you please help me out some more?
Thanks,
Felix

Leslie P. Polzer

unread,
Jul 8, 2010, 7:32:28 AM7/8/10
to webl...@googlegroups.com

fendres wrote:
> Ok, thanks. You seem to be right, but I got stuck halfway
> unfortunately. One problem I have is understanding the
> workings of slime, swank and sbcl.

SBCL is the Lisp itself. It comes with a REPL (command line)
-- try starting it directly in a terminal.

Swank runs in the Lisp and offers an interface for Slime
to connect to.

Slime (the client) is written in Emacs Lisp and runs
inside Emacs. It connects to Swank.


> If I eval something
> within an emacs buffer by M-C-x, where does that happen?

I'm not an Emacs user, but I think it evaluates as Emacs
Lisp within Emacs, not as Common Lisp within the remote
SBCL.


> It doesn't influence the environment started with M-x slime,
> right?

If I'm correct in the above the answer is no. It's not even
in the same Lisp dialect.


> I got confused about this. So the repl and the
> evaluations are two separate things, I guess...
> However I am not sure where the mentioned (C-c C-v i) should
> go for instance. Sorry if I am slow, but I don't really grasp it
> yet :-(.

It's complicated. Are you intent on using Slime for your Common
Lisp coding? Taking out Slime and using a decoupled editor
helps simplify things in the beginning.


> I managed to to connect to my mysql database by executing
> the clsql-tutorial.lisp file (from clsql/examples) with (load
> #p"...").
> However I during file evaluation I get an error after the connection
> is established:
> The value 0
> is not of type
> (OR (VECTOR CHARACTER) (VECTOR NIL) BASE-STRING SYMBOL
> CHARACTER).
> [Condition of type TYPE-ERROR]

What's your SBCL version? What's your CLSQL version?

Leslie


fendres

unread,
Jul 9, 2010, 9:27:05 AM7/9/10
to weblocks
Hi Leslie, thanks for your clarifications.

On Jul 8, 1:32 pm, "Leslie P. Polzer" <s...@viridian-project.de>
wrote:
> fendres wrote:
> > If I eval something
> > within an emacs buffer by M-C-x, where does that happen?
>
> I'm not an Emacs user, but I think it evaluates as Emacs
> Lisp within Emacs, not as Common Lisp within the remote
> SBCL.

I'm not sure about this, but the key combination is defined
by slime (I found it on http://www.cliki.net/SLIME%20Features),
so I don't think it is emacs' lisp.

> It's complicated. Are you intent on using Slime for your Common
> Lisp coding? Taking out Slime and using a decoupled editor
> helps simplify things in the beginning.

On the one hand it simplifies the process, but on the other hand
it is also helpful. Working in the sbcl repl is painful. And the repl
is supposed to be a key feature of lisp development, right?

>
> > I managed to to connect to my mysql database by executing
> > the clsql-tutorial.lisp file (from clsql/examples) with (load
> > #p"...").
> > However I during file evaluation I get an error after the connection
> > is established:
> > The value 0
> > is not of type
> >   (OR (VECTOR CHARACTER) (VECTOR NIL) BASE-STRING SYMBOL
> >       CHARACTER).
> >    [Condition of type TYPE-ERROR]
>
> What's your SBCL version? What's your CLSQL version?

I installed SBCL via aptitude. The version is: 1.0.29.11.debian.
I don't know where to geht the CLSQL version number from. I
installed it two weeks ago via clbuild, so it should be pretty recent.
The changelog file says, the last change was 2008 though.

Does this work for everybody else, or is this a general problem I
have?

I really wanted to get working on a new project and give lisp web
development a try, because I thought it would be an easy entry
(as compared to GUI development) and many people consider it
superior to php/perl/python.
So far it seems really hard to dive in. My usual ways of learning an
API and looking at given code, figuring out such problems don't work.
Googling errors doesn't work that well either, as the community is
tiny, and there is no way of getting a software bundle that you know
is in a coherent state.
I just hope that - with some help - I can put all the initial
problems
behind me.

Regards,
Felix

Rayservers

unread,
Jul 9, 2010, 10:08:31 AM7/9/10
to webl...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "weblocks" group.
> To post to this group, send email to webl...@googlegroups.com.
> To unsubscribe from this group, send email to weblocks+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/weblocks?hl=en.
>
>


This community though small, is very productive. SBCL itself is
evolving at a fast pace. You have to keep up with it... use clbuild,
use it to fetch and compile the latest sbcl, libraries etc. Most
often, as with Weblocks, you need the -dev or equivalent bleeding edge
as problems you are finding have been fixed and committed.

http://weblocks.viridian-project.de/installation

Make sure you edit the wnpp-projects file to keep up with the latest -
here is ours (The link will automatically keep up with our changes):

http://image.rayservers.com/wnpp-projects

Also, Leslie is a vim guru. That is an unusual combination in the Lisp
world, most of us are on emacs + slime. Lisp has always been for the
"keyboard artists" as I call them. The original Lisp machines were
amazing man-machine interfaces. In my view once you are familiar with
the quick instant compiles of just one function on slime, its hard to
go back to anything else. Being able to change a single function in a
running web server without a restart is unheard of in other
environments still. Also, the lisp process itself is long lived, you
can serve everything from RAM. In-memory object searching is way
faster than anything tied to disk. You just have to be clever about
persisting important data - this is something we are working on.

Cheers,

---Venkat.

--
http://www.rayservers.com/

Leslie P. Polzer

unread,
Jul 9, 2010, 10:18:25 AM7/9/10
to webl...@googlegroups.com

fendres wrote:

>> It's complicated. Are you intent on using Slime for your Common
>> Lisp coding? Taking out Slime and using a decoupled editor
>> helps simplify things in the beginning.
>
> On the one hand it simplifies the process, but on the other hand
> it is also helpful. Working in the sbcl repl is painful.

Not necessarily. Use `rlwrap' to start SBCL, and activate
SB-ACLREPL while we're at it:

rlwrap sbcl --eval "(require :sb-aclrepl)"

With this you have a good prompt, proper line editing and history.

It helps to have some basic knowledge of Readline's Emacs key
config.


> I installed SBCL via aptitude. The version is: 1.0.29.11.debian.
> I don't know where to geht the CLSQL version number from. I
> installed it two weeks ago via clbuild, so it should be pretty recent.
> The changelog file says, the last change was 2008 though.

The change log is probably stale. Try "git log" for a more
reliable indicator.

The latest release version is, according to the web site,

clsql-5.1.1.tar.gz (Sat, 15 May 2010 15:25:47, 870 KB)

Give it a try.

Also try some newer SBCL if it still doesn't work.

It's not hard to download the latest SBCL directly from
www.sbcl.org and use it.


> I really wanted to get working on a new project and give lisp web
> development a try, because I thought it would be an easy entry
> (as compared to GUI development) and many people consider it
> superior to php/perl/python.
> So far it seems really hard to dive in. My usual ways of learning an
> API and looking at given code, figuring out such problems don't work.
> Googling errors doesn't work that well either, as the community is
> tiny, and there is no way of getting a software bundle that you know
> is in a coherent state.
> I just hope that - with some help - I can put all the initial
> problems
> behind me.

You're right -- it's not easy to get started with Common Lisp
because so many things are different, and the community is
seriously understaffed.

But we've hardly let anyone walk away from here without having
made a serious effort to help them, and I think the same is true
for the communities of other Lisp projects.

"Don't give up" is the best advice I can give you; it will
definitely pay for itself later.

Oh, and do report back here if you experience any further
problems.

Leslie

Nandan Bagchee

unread,
Jul 11, 2010, 11:04:56 PM7/11/10
to webl...@googlegroups.com
Sorry, I seem to be coming back to this thread after a while.

Did you get thru the making of the sqlite3 database fine? Are you able to connect *at all* using clsql? 
 
Ok, thanks. You seem to be right, but I got stuck halfway
unfortunately. One problem I have is understanding the
workings of slime, swank and sbcl. If I eval something
within an emacs buffer by M-C-x, where does that happen?
It doesn't influence the environment started with M-x slime,
right? I got confused about this. So the repl and the
evaluations are two separate things, I guess...
However I am not sure where the mentioned (C-c C-v i) should

The C-c C-v i was not necessary, I only used it to illustrate how to "inspect" an object in the REPL (the swank repl, that is). I apologize for bringing in swank-slime stuff, that's just confused the issue at hand, which is clsql+sbcl.

You can also do (describe *some-var*) or (inspect *some-object*) instead at a plain repl.
 
I managed to to connect to my mysql database by executing
the clsql-tutorial.lisp file (from clsql/examples) with (load
#p"...").

That sounds like a promising first step.

I would recommend the following steps to see where we're at:

Start a fresh repl [a],  and get to the step above where (load #p"..") is successful.

[a] -- preferably with `rlwrap sbcl` at a bash/shell prompt, or see Leslie's start cmd with aclrepl

Then at the repl type: clsql::*default-database* and after pressing enter, type (clsql::connected-databases)

What are the values of those expressions?
 
However I during file evaluation I get an error after the connection
is established:
The value 0
is not of type
 (OR (VECTOR CHARACTER) (VECTOR NIL) BASE-STRING SYMBOL

We'll handle this when we know if *default-database* is set properly! 

Also, stick with it, the lisp way is certainly different, but a lot more fun and productive! And actually, once everything is set up properly, jumping around in the weblocks code is very easy, at least in emacs with M-. (but the combination of lisp + learning emacs is a bit tough). A graphical emacs helps, in many cases you can just right click and choose from a menu, eg in the slime repl you can right click and choose inspect instead of C-c C-v i 

I was in the same position as you a few years back (we've all been there, I guess!) -- but I conquered the emacs beastie in the terminal, and so I highly recommend a graphical beastie -- easier to slay!

Lastly, I have also found clsql a bear because it depends on uffi/cffi -- luckily you don't seem to be having those problems, and I think we can get you over the hump quite quickly. FWIW, I used cl-prevalence, because it was easy to deal with (you just work with lisp objects, link them however you like, and you don't need to worry about a DB at all -- imho rather than using an ORM, just use an object DB like cl-prevalence -- if I'm not mistaken, that's what Venkat's project does in some form -- a distributed object db). 

But perhaps your project depends on connecting to a legacy database? To be fair, I did use clsql to suck out all the data from a MS Sqlserver database, and munge it into our CLOS objects, and it worked flawlessly for that, so it's just that it's sometimes a bit hard to get started with it.

hth,
 nandan


Reply all
Reply to author
Forward
0 new messages