Hi,
I have a gridedit widget which I'd like to use to allow the user to perform
modifications on the listed items.
Using drilldown-type :edit works out-of-the-box, however, when I perform some
change and click on "Submit", it fails since it tries to insert a new record
in the database, instead of updating it by pk.
Looking at the clsql documentation (generics.lisp):
(defgeneric update-records-from-instance (object &key database)
(:documentation
"Using an instance of a View Class, OBJECT, update the table
that stores its instance data. DATABASE defaults to
*DEFAULT-DATABASE* and specifies the database in which the update
is made only if OBJECT is not associated with a database. In this
case, a record is created in the appropriate table of DATABASE
using values from the slot values of OBJECT, and OBJECT becomes
associated with DATABASE."))
It seems the problem is that the instance is somehow detached from the
database. The call to (view-database obj) is returning nil.
However, I see nothing special in my def-view-class:
(clsql:def-view-class printer ()
((printer_id :accessor printer_id
:initarg :printer_id
:db-kind :key
:initform (get-new-printer-id)
:db-constraints (:not-null :unique)
:type integer)
(name :accessor printer_name
:initarg :printer_name
:initform ""
:db-constraints (:not-null :unique)
:type string
:column name
:documentation "The printer name")
(agency_id :initarg :agency_id
:accessor agency_id
:db-constraints :not-null
:initform (if (boundp 'hunchentoot:*request*) (get-session-agency-
id) 0)
:type integer)
(media :initarg :media
:accessor printer-media
:type string
:initform ""
:column media
:documentation "The media")
(tickets-per-job :initarg :tickets-per-job
:accessor printer-tickets-per-job
:type integer
:initform 500
:column tickets_per_job
:db-constraints (:not-null)
:documentation "The number of tickets send in a batch.")
(orientation :initarg :orientation
:accessor printer-orientation
:type string
:initform "P"
:db-constraints (:not-null)
:column orientation
:db-reader read-orientation
:db-writer write-orientation
:documentation "The orientation. Either P (portrait) or L
(landscape).")
(rotate :initarg :rotate
:accessor printer-rotate
:type integer
:initform 0
:db-constraints (:not-null)
:column rotate
:documentation "The degrees to rotate the ticket.")
(x-offset :initarg :x-offset
:accessor printer-x-offset
:type integer
:initform 12
:db-constraints (:not-null)
:column x_offset
:documentation "The horizontal offset, in mm.")
(y-offset :initarg :y-offset
:accessor printer-y-offset
:type integer
:initform 2
:db-constraints (:not-null)
:column y_offset
:documentation "The vertical offset, in mm.")
(x-gap :initarg :x-gap
:accessor printer-x-gap
:type integer
:initform 0
:db-constraints (:not-null)
:column x_gap
:documentation "The horizontal gap, in mm.")
(y-gap :initarg :y-gap
:accessor printer-y-gap
:type integer
:initform 0
:db-constraints (:not-null)
:column y_gap
:documentation "The vertical gap, in mm.")
(width :initarg :width
:accessor printer-width
:type integer
:initform 160
:db-constraints (:not-null)
:column width
:documentation "The media width, in mm.")
(height :initarg :height
:accessor printer-height
:type integer
:initform 104
:db-constraints (:not-null)
:column height
:documentation "The media height, in mm.")
(horizontal-scale :initarg :horizontal-scale
:accessor printer-horizontal-scale
:type float
:initform 2.962
:db-constraints (:not-null)
:column h_scale
:documentation "The horizontal scale factor.")
(vertical-scale :initarg :vertical-scale
:accessor printer-vertical-scale
:type float
:initform 2.89
:db-constraints (:not-null)
:column v_scale
:documentation "The vertical scale factor."))
(:base-table pv_printers))
Am I missing something? The gridedit lists items ("printers") just fine. How
can be considered 'detached' from the database?
Sorry if this is a clsql question.
--
You received this message because you are subscribed to the Google Groups
"weblocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/weblocks?hl=en.