 
 (defn execute-request-handler [shell-socket iopub-socket executer]
   (let [execution-count (atom 0N)]
-    (fn [message]
+    (fn [message signer]
       (let [session-id (get-in message [:header :session])
             parent-header (:header message)]
         (swap! execution-count inc)
         (send-message iopub-socket "status" (status-content "busy")
-                      parent-header {} session-id)
+                      parent-header {} session-id signer)
         (send-message iopub-socket "pyin" (pyin-content @execution-count message)
-                      parent-header {} session-id)
+                      parent-header {} session-id signer)
         (send-message shell-socket "execute_reply"
                       {:status "ok"
                        :execution_count @execution-count

;  (println "Sending message " msg)
  (zmq/send socket (.getBytes msg)))

(defn kernel-info-reply [message socket]
  (let [header (kernel-info-header message)
        parent_header (cheshire/generate-string (:header message))
        metadata (cheshire/generate-string {})
        content  (cheshire/generate-string kernel-info-content)]
    (send-message-piece socket (get-in message [:header :session]))
    (send-message-piece socket "<IDS|MSG>")
    (send-message-piece socket "")
    (send-message-piece socket header)
    (send-message-piece socket parent_header)
    (send-message-piece socket metadata)

         (binding [*ns* user-ns] (eval (read-string request)))
         (catch Exception e (.getLocalizedMessage e)))))))

(defn history-reply [message signer]
  "returns REPL history, not implemented for now and returns a dummy message"
  {:history []})

(defn configure-shell-handler [shell-socket iopub-socket signer]
  (let [execute-request (execute-request-handler shell-socket iopub-socket
                                                 (get-executer))]
    (fn [message]
      (let [msg-type (get-in message [:header :msg_type])]
        (case msg-type
          "kernel_info_request" (kernel-info-reply message shell-socket signer)
          "execute_request" (execute-request message signer)
          "history_request" (history-reply message signer)
          (do
            (println "Message type" msg-type "not handled yet. Exiting.")
            (println "Message dump:" message)
