[Bese-devel] Several beginner's questions

Marco Baringer mb at bese.it
Wed Aug 3 11:46:09 UTC 2005


Marco Simon <marco_simon at web.de> writes:

> Hi ucw-list,
>
> I've been trying to set up and understand the ucw-system for
> some days now, but I'm still fighting with some beginners problems.
>
> First of all, the myhost/ucw/examples/index.ucw works fine.
>
> What I don't understand so far:
> There are several subdirectories within the /ucw - tree, and
> I'm not sure if I got their function right so far.
>
> /ucw/examples/ seems to be the application-directory for the
> dynamic-part of the demo-application. This is the place where
> I have to change the code if I want to modify the ucw-servers
> webpage-output.

yes, but i think you're missing the point.

inside ucw/examples are a bunch of files which, when _loaded_, will
create some objects and functions in the lisp image which causes the
url '/ucw/examples/index.ucw' to do what it does. changing those files
is not enough (and, often, not neccessary), what's important is to
change the things those files define.

for example: load up ucw (using the start.lisp script or bobstopper's
new control.lisp stuff). then connect to the lisp and simply type:

(defmethod render-on ((res response) (welcome example-welcome))
  (<:as-html "Hello, World!"))

that will change the html generated by the home page. you needn't edit
or save or even have a copy of the example.lisp file which contains
the original definition of render-on.

> /ucw/wwwroot seems to hold some static files (like the stylesheet.css)
> as well as some dynamic parts of the demo application (the counter-demo
> doesn't work without this directory). Besides that, this directory must be
> reachable by apache (or even better must be its document-root) for
> serving static files like images and css-files, right ?

countre-demo doesn't work because i put static and tal files in the
same directory (this probably isn't such a great idea). the counter
component uses a TAL file (which is one of the many templating tools
for lisp) and so won't work without that file. had you defined a
render-on method for the counter component you wouldn't need that
directory.

> /ucw/bin/ holds the start-skript and initialisation-files.

yes.

> /ucw/logs/ is the place for all ucw log files

yes, but only because of this:

(setup-loggers (make-pathname :name nil :type nil
                              :directory (append (pathname-directory *load-truename*)
                                                 (list :up "logs"))
                              :defaults *load-truename*)
               +info+)

which is located in bin/start.lisp. you colud just as well do:

(setup-loggers "/var/log/ucw/" +info+)

and you'd no longer need ucw/logs/

> /ucw/var/ holds the socket and pid files

yes, but only because of what we pass to detachtty in ucwctl.

> /ucw/doc/ is more or less empty. Just keeps some issue and todo-infos.

correct.

> /ucw/src/ mh - I'm not really clear about this directory's content.

that directory holds the source code for uncommon web itself.

> After I got running the /ucw/examples/index.ucw I tried to follow your
> great "hello-world" movie. But I'm stuck several times.
>
> The very first problem: My emacs/slime/cmucl environment doesn't know
> the it.bese.ucw-user package. So I tried just to do a
> (load /home/ucw/src/packages.lisp)
> After ignoring the following compilation-errors (via "make this package"):
> Type-error in LISP::PAGAGE-OR-LOSE: "IT.BESE.ARNESI" is not of type
> PACKAGE
> Type-error in LISP::PAGAGE-OR-LOSE: "IT.BESE.YYCLML" is not of type
> PACKAGE
> Type-error in LISP::PAGAGE-OR-LOSE: "ITERATE" is not of type PACKAGE
> I was able to change-package to IT.BESE.UCW-USER.
> Next step was typing the first lines of your hello world demo in the
> repl (for debugging reasons).
> What made me write you this mail finally, was the following error:
>
> CL-USER> (load "/home/ucw/ucw/src/packages.lisp")
> ; Loading #p"/home/ucw/ucw/src/packages.lisp".
> T
> CL-USER>
> UCW-USER> (in-package :it.bese.ucw-user)
> #<The IT.BESE.UCW-USER package, 0/9 internal, 0/2 external>
> UCW-USER> (defvar *hello-world* (make-instance
> 'cookie-session-application :url-prefix "/hello/" ))
>
> Error in function PCL::FIND-CLASS-FROM-CELL:
>    No class named COOKIE-SESSION-APPLICATION.
>    [Condition of type SIMPLE-ERROR]
>
> Restarts:
>   0: [ABORT] Abort handling SLIME request.
>   1: [ABORT] Return to Top-Level.

loading the packages file defines the packages but does _not_ load up
the rest of the code. se while you've told lisp that there's a package
named :it.bese.ucw and that that packgae has an external symbol named
cookie-session-application, you haven't created the class and much
less bound it to the proper name.

you'll notice that one of the first things start.lisp does is this:

(asdf:oos 'asdf:load-op :ucw)

this causes the package file to be loaded up (first) and then it loads
up the rest of ucw itself. notice that in ucw.asd we have a list of
every file in ucw/src with their dependencies.

> I guess I've made some fundamental mistake at the very beginning and
> I would be glad if you could give some hints and further explication.

i think you're only mistako is not realizing how lisp code is loaded
and what the association between file and a running lisp is.

hth.

-- 
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen



More information about the bese-devel mailing list