Quick Lisp-on-Lines tutorial (was Re: [Bese-devel] yet another question (suggestion?))
Friedrich Dominicus
frido at q-software-solutions.de
Mon Aug 29 10:07:55 UTC 2005
Drew Crampsie <drewc at tech.coop> writes:
> Friedrich Dominicus wrote:
>> Drew Crampsie <drewc at tech.coop> writes:
>>
>>>Friedrich Dominicus wrote:
>
>> Here's the requested stuff. I have however quite few questions:
>> I have a clsq database model. Is it possible to just exchange
>> def-view-class with the here mentioend macro?
>
> Might work, unless your model happens to use inheritance, in which
> case not without adding support for inheritance to LoL.
>
>> I tried to get hairierpub running, but without tweaking the files it
>> failed here:
>
> The version of hairiepub that is in that repo probably does not
> build. The whole thing is in a big state of flux right now, and has
> never been released anyway.
Well I feel that is unfair, the README contains the following:
> HairiePub requires LISP-ON-LINES, cl-l10n and POSTGRESQL
>
> Add the following lines to your /etc/postgres/pg_hba.conf
>
> ## HairiePub User
> local all hairiepub password
> host all hairiepub 127.0.0.1 255.255.255.255 password
>
> And then create a user and a database in postgres :
>
> template1=# CREATE USER hairiepub PASSWORD 'hp01';
> CREATE USER
> template1=# CREATE DATABASE hairiepub OWNER hairiepub;
> CREATE DATABASE
>
> Once you've done that you are ready to create that database. There is a file 'database/sql-schema.lisp'. Load it into a running lisp (i use C-c C-k in slime) to create the database.
>
> Make sure ASDF can see the system :
>
> drewc at osiris:~/.sbcl/systems $ ln -s /home/drewc/src/hairiepub/hairiepub.asd /home/drewc/.sbcl/systems/
>
>
> once you've done that, it should be a simple matter of running './bin/ucwctl start && ./bin/ucwctl attach'
>
>
So I can't see that it's not supposed to work.
>
>> I'm (more and more) sceptical about the usefullness of ucw and sorry
>> hairiepub does not help to improve on my doubts.
>
> Well, pulling pre-alpha software and expecting it to work
> out-of-the-box is a little crazy.
Well then you should at least mention it.
>
> [snipped whining]
Well it was an exact description on all the things going wrong. So why
do you start blaming me of whining? I send it to you because I though
you might be interested, sorry for misjudging you.
> I don't know what post you are refering to, but the likely reason
> nobody has answered it is because it is not a "smart question". See
> http://www.catb.org/~esr/faqs/smart-questions.html for details about
> what i mean.
Well I repeat this question that you got an idea. I don'f feel that
the question was too dump.
(defaction shop-login ((login shop-login) username password)
(setf (login.username login) username
(login.password login) password)
(let* ((user-data (check-credentials login))
(shipping-adr (make-instance 'shipping-adr :adr (car (qss.db::shipping-address user-data)))))
;; car is needed because a join slot always returns a list!
(inspect login)
(inspect shipping-adr)
(if shipping-adr
(call 'customer-input-page
:customer-data user-data
:address shipping-adr
:payment-details nil)
(call 'info-message
:message "Login failed"))))
The shipping-adr class is defined this way:
(defcomponent address-mixin ()
((adr :initarg :adr :accessor adr
:backtrack t
:initform (make-instance 'qss.db::shipping-address)))
(:metaclass standard-component-class))
;; (forget-class :shipping-adr)
(defclass shipping-adr (address-mixin)
()
(:metaclass standard-component-class))
If I inspect login I see the following:
0. CONTINUATION: (IT.BESE.ARNESI::TOPLEVEL-K)
1. CALLING-COMPONENT: #<TRANS-INFO {1001F24851}>
2. PLACE: #<IT.BESE.UCW::PLACE (CONTEXT.WINDOW-COMPONENT
*CONTEXT*) {1001391471}>
that's ok, the shipping-adr has the following
0. CONTINUATION: "unbound"
1. CALLING-COMPONENT: "unbound"
2. PLACE: "unbound"
which seems itself reasonable, but then I do the following
(defmethod render-on ((res response) (customer-page customer-input-page))
(<:h1 "Your adress data: ")
(render-on res (address customer-page)))
which then calls this:
(defmethod render-on ((res response) (adr shipping-adr))
(let ((address (adr adr)))
(inspect adr)
(<ucw:form :action (edit-address adr)
(<:table
(dolist (item '(street zip city country email))
(present-a-slot-as-table-row item (slot-value address item))))
(<:p
(<ucw:submit :action (edit-address adr)
:value "Edit")))))
This is rendered fine.
But then I push the button and got:
The slot IT.BESE.UCW::PLACE is unbound in the object #<SHIPPING-ADR {10017C2171}>.
[Condition of type UNBOUND-SLOT]
Restarts:
0: [SHOW-BACKTRACE] Send the client a backtrace page.
1: [RETRY] Clearout the response and retry calling the action.
2: [SERVER-ERROR] Send the client an internal server error page.
3: [GENERATE-BACKTRACE-FOR-EMACS] Generate a bug report in Emacs.
That's of course true, but not what I like to see of course I'd like
to call the next action and go on from there.
So how am I supposed to build such a action-render-render-action
chain?
what i want is:
checking the login credentials
if the the customer can be found then show me his/her address
if the data have changed allow to change them
change the data
display the changed data
go on wiht the state as if he/she had not changed the address
display e.g the payment terms the customer has taken.
allow changes as needed
etc.
Help would be very appreciated.
>
> Also, when someone gives you a good detailed answer, responding as you
> did to this one will probably piss them off enough to not care about
> your problems anymore.
Well I can not see in any message that I'd made someone down. Oh, well
I asked dump question also but if I thought I had to ask them one can
assume that I had my reasons. Now I'm getting a bit angry about your
wording. I did spend a lot of time getting things going. I wrote > 30
k code to implement a shop solution. It took me a lot of work and I run
into all kind of troubles. What I especially dislike about your
wording is that you insnuate that I did not try. And what I dislike
also is that it seems one is not allowed to criticize things. You made
your stuff available as example I suppose. I tried it. I followed you
instructions but it turned out that it won't work the intended way, I
send you a long reply about the toubles, but instead of saying. "yeah,
there are problems" are you starting flaming around. If you feel that
is ok, well go for it. I won't bother you again.
Friedrich
More information about the bese-devel
mailing list