duck1123
9/6/2009 - 4:48 PM

gistfile1.txt

;; src/main/clojure/net/mycyclopedia/view.clj

(ns net.mycyclopedia.view
  (:use net.mycyclopedia.model
        clojure.contrib.pprint
        clojure.contrib.lazy-xml
       (compojure.http helpers)
        (compojure.html form-helpers
                        gen
                        [page-helpers :exclude (link-to)]))
  (:require (net.mycyclopedia.model
             [auth :as model.auth]
             [user :as model.user])
            (clojure.contrib.json
             [write :as json.write])))

;; ...

(defn redirect
  ([location]
     {:status 300
      :headers {"Location" location}})
  ([location message]
     [(flash-assoc :message message) 
      (redirect location)]))

;; end file

;; src/main/clojure/net/mycyclopedia/model/auth.clj

(ns net.mycyclopedia.model.auth
  (:use net.mycyclopedia.view
        (compojure.http
         [session :only (session-assoc session-dissoc flash-assoc)]))
  (:require (net.mycyclopedia.config
             [config :as config])
            (net.mycyclopedia.model
             [identity :as model.identity]
             [user :as model.user]))
  (:import (org.openid4java.consumer ConsumerManager)
           (org.openid4java.message ParameterList)))


;; ...

(defn verify
  [request]
  (let [verification (get-verification request)
        verified (verified-identifier verification)]
    (if (not (nil? verified))
      (let [auth-success (.getAuthResponse verification)
            url (.getIdentifier verified)]
        (if-let [identity (first (model.identity/find-records {:url url}))]
          (let [user (model.identity/get-user identity)]
            {:success true
             :redirect true
             :url "/home"
             :user user})
          (net.mycyclopedia.view/redirect (format "/register?url=%s" url))))
      (net.mycyclopedia.view/redirect "/login" "Invalid authentication"))))

;; end file

;; stacktrace

Exception in thread "main" java.lang.Exception: No such var: net.mycyclopedia.view/redirect (auth.clj:103)
        at clojure.lang.Compiler.analyze(Compiler.java:4388)
        at clojure.lang.Compiler.analyze(Compiler.java:4334)
        at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2815)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4553)
        at clojure.lang.Compiler.analyze(Compiler.java:4373)
        at clojure.lang.Compiler.analyze(Compiler.java:4334)
        at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:2729)
        at clojure.lang.Compiler.analyze(Compiler.java:4375)
        at clojure.lang.Compiler.analyze(Compiler.java:4334)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3910)
        at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:4157)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:4551)
        at clojure.lang.Compiler.analyze(Compiler.java:4373)