removing historical implementation
[clinton/lisp-on-lines.git] / src / lisp-on-lines.lisp
index 465ec5f..911b02d 100644 (file)
@@ -7,8 +7,48 @@
 ;;;; that are part of LoL proper, that is to say, not Mewa 
 ;;;; or Meta-Model.
 
+
+
+(defmacro action (args &body body)
+  `(lambda ,args
+    (with-call/cc
+      ,@body)))
+
 ;;;; ** Initialisation
+(defmethod find-default-attributes ((object t))
+  "return the default attributes for a given object using the meta-model's meta-data"
+  (append (mapcar #'(lambda (s) 
+                     (cons (car s) 
+                           (gen-pslot 
+                            (if (meta-model:foreign-key-p object (car s))
+                                'foreign-key
+                                (cadr s))
+                            (string (car s)) (car s)))) 
+                 (meta-model:list-slot-types object))
+         (mapcar #'(lambda (s) 
+                     (cons s (append (gen-pslot 'has-many (string s) s) 
+                                     `(:presentation 
+                                       (make-presentation 
+                                        ,object 
+                                        :type :one-line)))))
+                 (meta-model:list-has-many object))
+         (find-default-presentation-attribute-definitions)))
+
+(defmethod set-default-attributes ((object t))
+  "Set the default attributes for MODEL"
+  (clear-attributes object)
+  (mapcar #'(lambda (x) 
+             (setf (find-attribute object (car x)) (cdr x)))
+         (find-default-attributes object)))
+
+;;;; This automagically initialises any meta model
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defmethod meta-model::generate-base-class-expander :after (meta-model name args)
+    (set-default-attributes name)))
+
 ;;;; The following macros are used to initialise a set of database tables as LoL objects.
+
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defun generate-define-view-for-table (table)
     "
@@ -16,8 +56,8 @@ Generates a form that, when evaluated, initialises the given table as an lol obj
 This involves creating a meta-model, a clsql view-class, and the setting up the default attributes for a mewa presentation"
 
     `(progn 
-      (def-view-class-from-table ,table)
-      (set-default-attributes (quote ,(meta-model::sql->sym table))))))
+       (rofl::gen-view-class ,table :generate-joins :all)
+       (set-default-attributes (quote ,(meta-model::sql->sym table))))))
     
 (defmacro define-view-for-table (&rest tables)
   " expand to a form which initialises TABLES for use with LOL"
@@ -29,43 +69,6 @@ This involves creating a meta-model, a clsql view-class, and the setting up the
   "expands to init-i-f-t using the listing of tables provided by meta-model"
   `(define-view-for-table ,@(meta-model::list-tables)))
 
-(eval-when (:compile-toplevel :load-toplevel :execute)
-  (defun %make-view (object type &rest attributes-and-args)
-    (let ((attributes (car attributes-and-args))
-         (args (cdr attributes-and-args)))
-      `(mewa:make-presentation
-       ,object
-       :type ,type
-       :initargs
-       '(,@ (when attributes
-              `(:attributes ,attributes))) 
-       ,@args)))) 
-
-(defmethod make-view (object &rest args &key (type :viewer) (attributes nil)
-                     &allow-other-keys )
-  (apply #'make-presentation (cdr (%make-view object type (cons attributes args)))))
-
-(defmacro present-view ((object &optional (type :viewer))
-                       &body attributes-and-args)
-  `(present ,(%make-view object type attributes-and-args)))
-
-
-(defmacro call-view ((object &optional (type :viewer) (component 'self component-supplied-p))
-                    &body attributes-and-args)
-  
-  
-  `(ucw:call-component
-    ,component
-    ,(%make-view object type attributes-and-args)))
-
-(defmethod slot-view ((self mewa) slot-name)
-  (mewa::find-attribute-slot self slot-name))
-
-(defmethod present-slot-view ((self mewa) slot-name &optional (instance (instance self)))
-  (present-slot (slot-view self slot-name) instance))
-
-
-
 
 (defmethod find-slots-of-type (model &key (type 'string)
                              (types '((string)) types-supplied-p))
@@ -79,6 +82,10 @@ This involves creating a meta-model, a clsql view-class, and the setting up the
             (lisp-on-lines::list-slot-types model)))))
 
 
+
+
+
+
 (defmethod word-search (class-name slots search-terms 
                        &key (limit 10) (where (sql-and t)))
   (select class-name 
@@ -90,8 +97,7 @@ This involves creating a meta-model, a clsql view-class, and the setting up the
 
 
 (defmethod word-search (class-name slots (s string) &rest args)
-  (apply #'word-search class-name slots 
-        (split-sequence:split-sequence #\Space s) args))
+  (apply #'word-search class-name slots (list s) args))
 
 (defmethod word-search-where (class-name slots search-terms &key (format-string "%~a%"))
   (sql-or 
@@ -104,3 +110,5 @@ This involves creating a meta-model, a clsql view-class, and the setting up the
                              slots)))
           search-terms)))
 
+
+  
\ No newline at end of file