Permalink
Browse files

added define-default-render-method macro and

fix small bug
  • Loading branch information...
1 parent 44a8c29 commit 5ec798d756882335f27bf1d4712e853d2b634629 @archimag committed Mar 28, 2010
Showing with 25 additions and 12 deletions.
  1. +4 −2 src/hunchentoot.lisp
  2. +20 −10 src/module.lisp
  3. +1 −0 src/packages.lisp
View
@@ -124,7 +124,9 @@
(defun start (module &key hostname (port 80) (context (make-context))
&aux (hostname/port (if hostname (format nil "~A:~A" hostname port))))
- (let* ((acceptor (or (find port
+ (let* ((package (or (find-package module)
+ (error "Package ~A not found" module)))
+ (acceptor (or (find port
*acceptors*
:key #'hunchentoot:acceptor-port)
(car (push (hunchentoot:start (make-instance 'restas-acceptor
@@ -142,7 +144,7 @@
:host hostname/port)
(restas-acceptor-vhosts acceptor))))))
(push (make-instance 'submodule
- :module module
+ :module package
:context context)
(slot-value vhost 'modules))
(reconnect-all-routes)))
View
@@ -70,7 +70,8 @@
(defgeneric module-routes (module submodule)
(:documentation "List routes of the module")
(:method ((module symbol) submodule)
- (module-routes (find-package module)
+ (module-routes (or (find-package module)
+ (error "Module ~A not found" module))
submodule)))
(defun submodule-routes (submodule)
@@ -110,14 +111,6 @@
(defparam +content-type-symbol+ ',(second (assoc :default-content-type options )))
*package*)))))
-(defmacro define-initialization ((context) &body body)
- `(defmethod initialize-module-instance ((module (eql ,*package*)) ,context)
- ,@body))
-
-(defmacro define-finalization ((context) &body body)
- `(defmethod finalize-module-instance ((module (eql ,*package*)) ,context)
- ,@body))
-
(defmethod module-routes ((module package) submodule)
(alexandria:flatten (list* (iter (for route-symbol in-package (symbol-value (find-symbol +routes-symbol+ module)))
(collect (create-route-from-symbol (find-symbol (symbol-name route-symbol)
@@ -143,4 +136,21 @@
:context context))
(initialize-module-instance ',module context))
(eval-when (:execute)
- (reconnect-all-routes)))))
+ (reconnect-all-routes)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; Macros for simplify develop modules
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defmacro define-initialization ((context) &body body)
+ `(defmethod initialize-module-instance ((module (eql ,*package*)) ,context)
+ ,@body))
+
+(defmacro define-finalization ((context) &body body)
+ `(defmethod finalize-module-instance ((module (eql ,*package*)) ,context)
+ ,@body))
+
+(defmacro define-default-render-method ((data) &body body)
+ `(setf ,(find-symbol +render-method-symbol+ *package*)
+ #'(lambda (,data)
+ ,@body)))
View
@@ -23,6 +23,7 @@
#:define-initialization
#:define-finalization
+ #:define-default-render-method
#:*route*

0 comments on commit 5ec798d

Please sign in to comment.