Browse Source

Started the define-application macro

Samuel W. Flint 9 years ago
parent
commit
9020c93a94
1 changed files with 24 additions and 0 deletions
  1. 24 0
      collect.lisp

+ 24 - 0
collect.lisp

@@ -6,6 +6,30 @@
 
 ;;; "collect" goes here. Hacks and glory await!
 
+(defmacro define-application (name file &body body-forms)
+  (declare (string name))
+  `(progn
+     (restas:define-module ,name
+       (:use :cl
+             :cl-who
+             :parenscript
+             :sqlite
+             :restas
+             :iter)
+       (:import-from #:hunchentoot
+                     #:post-parameter)
+       (:import-from #:lass
+                     #:compile-and-write))
+     (in-package ,name)
+     (defvar *tables*)
+     (defvar *db*)
+     (defun start (port)
+       (setq *db* (connect ,file))
+       (iter (for (name . query))
+             (do (execute-non-query *db* query)))
+       (restas:start ,name :port 8080))
+     ,@body-forms))
+
 (defun to-sql-type (type)
   (cadr (assoc type '((:integer "INTEGER")
                       (:text "TEXT")