[Bese-devel] another question about the ucw way

Friedrich Dominicus frido at q-software-solutions.de
Sat Aug 20 07:08:51 UTC 2005


Ok, I'm back again ;-(, let me introduce a simple example
assume you'd ahve the class
(defclass foo ()
          ((num-1 ...)
           (num-2 ...)
           ... some other slots))


Now you like to present it so you write a render-on method.
(defmethod render-on ((res response) (foo foo))
.... 
all you need to render that class.

Now you want to be able to edit the slots of the class foo. So you'd
need another render-on method but you still have the first one, so
what are you supposed to do? 

it may be that my understanding of ucw is so sparse (despite the fact
that I spend now at least 3 weeks on it), that I can't see the obvious
but for me there is no way to write different render-on
methods for one class. On the other hand even if there would I see
that  lot of code would have to be duplicated, but the difference is
just:
one time you like to have an editable view and the other time you just
want a "read-only" view. 

The clumsy workaround I think I have to take is
declare diverse classes
(defclass foo ()
....

(defclass editable-foo()....

and the like. However I would need to copy the slots over to the new
class just for the filling the slots and write another method. So I
had to write nearly identical classes over and over again and copy
values from one class to another. This can't be the "right" solution. 

A solution might be adding another parameter to the render-on method
which is named view. Of course one would have to write specialiced
methods for the different views but one would not have to invent
things like editable-foo. 

The render-on method would then look like
(defgeneric render-on (response class view))
(defmethod render-on ((res response) (foo foo) (editable-view
editable-view))

What is your opinion about that? 
Have I missed the obvious ucw way?


Regards
Friedrich



More information about the bese-devel mailing list