[Bese-devel] questions

Vladimir Sekissov svg at surnet.ru
Wed Sep 21 09:41:17 UTC 2005


Good day,

frido> "Marco Baringer" <mb at bese.it> writes:
frido> 
frido> >
frido> > no, it falls into the "think of a good way and help marco implement
frido> > it". i'd really really like to see ucw have a nice form api
frido> > (validation, marshalling and java script alerting are good starting
frido> > points), i just can't seem to come up with it. this would be as good a
frido> > time as any to start stealing ideas from other libs.
frido> >
frido> > in the mean time we could setup an initialize-instance method
frido> > which passed initargs to slots which were know to be form elements. or
frido> > even better we could create a form-class (a subclass of
frido> > standard-component-class) and all the bells and whistles we want. we'd
frido> > just need to come up with a short list of what a form class sholud
frido> > look like and rework the form components (i'd be more than happy to
frido> > put time into this).
frido> 
frido> Well I have asked similiar stuff before and was looking for a
frido> "somehwat" nice solution. However what I thought and think about this
frido> is to have the backend (application) and the frontend (UCW-views)
frido> synced. I've now come up with something along this lines:
frido> 
frido> (in-package :qss.web)
frido> 
frido> ;; (use-package :cells)

I think Cells is surplus for UCW. I'm trying to use slightly more light-wait
solution using proxy slots and MOP (not yet fully tested):


Example:

(defcomponent my-component ()
  ((my-field :accessor my-field
             :initarg my-field
             :initform (make-indirect-value)
   ...
  )
  (:metaclass indirect-value-standard-component-class))

(defmethod set-inderect-object ((comp my-component) obj)
   (setf (indirect-object (my-field comp) obj))
   ...
 )


Code:

(defstruct (indirect-value (:named t)
                           (:conc-name indirect-)
                           (:type list))
  object
  (reader #'slot-value)
  (writer #'(lambda (obj slot-name new)
              (setf (slot-value obj slot-name) new))))
                           
(defclass indirect-value-mixin-class (standard-class)
  ()
  (:documentation "Metaclass for INDIRECT-VALUE-CLASS-MIXIN."))

(defmethod mopp:validate-superclass ((class indirect-value-mixin-class) (superclass standard-class))
  t)

(defmethod (mopp:slot-value-using-class) ((class indirect-value-mixin-class) obj slot-name)
  (let (value (call-next-method))
    (if (indirect-value-p value)
        (funcall (indirect-reader value)
                 (indirect-object value)
                 slot-name)
        value)))

(defmethod (setf mopp:slot-value-using-class) (new (class indirect-value-mixin-class) obj slot-name)
  (let (value (mopp:slot-value-using-class (find-class 'standard-class) obj slot-name))
    (if (indirect-value-p value)
        (funcall (indirect-writer value)
                 (indirect-object value)
                 slot-name
                 new)
        (call-next-method))))

(defclass indirect-value-standard-component-class (standard-component-class indirect-value-mixin-class)
  ())

Best Regards,
Vladimir Sekissov



More information about the bese-devel mailing list