Permalink
Browse files

Fixing up licensing

  • Loading branch information...
alsonkemp committed Nov 26, 2008
1 parent 08d621a commit 9a9af21a2e89a317c4a796cadf627b55a55077da
View
10 LICENSE
@@ -0,0 +1,10 @@
+Copyright (c) 2008, Turbinado.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -2,15 +2,11 @@
-----------------------------------------------------------------------------
-- |
-- Module : Turbinado.Exception
--- Copyright : (c) Niklas Broberg 2008
--- License : BSD-style (see the file LICENSE.txt)
+-- Copyright : (c) Alson Kemp, Niklas Broberg 2008
+-- License : BSD-style (see the file LICENSE)
--
--- Maintainer : Niklas Broberg, nibro@cs.chalmers.se
+-- Maintainer : Alson Kemp (alson@alsonkemp.com)
-- Stability : experimental
--- Portability : needs dynamic exceptions and deriving Typeable
---
--- Defines a datatype for runtime exceptions that may arise during
--- the evaluation of a Turbinado page.
-----------------------------------------------------------------------------
module Turbinado.Controller.Exception (
Exception(..),
@@ -1,17 +1,16 @@
-----------------------------------------------------------------------------
-- |
--- Module : Turbinado.RequestHandler
--- Copyright : (c) Niklas Broberg 2004,
--- License : BSD-style (see the file LICENSE.txt)
+-- Module : Turbinado.Server.Handlers.RequestHandler
+-- Copyright : (c) Alson Kemp 2008, Niklas Broberg 2004,
+-- License : BSD-style (see the file LICENSE)
--
--- Maintainer : Niklas Broberg, d00nibro@dtek.chalmers.se
+-- Maintainer : Alson Kemp, Alson@AlsonKemp.com
-- Stability : experimental
-- Portability : portable
--
-- A utility for the server that handles a recieved request, producing
-- a response.
--
--- TODO: * Session variable handling
-----------------------------------------------------------------------------
module Turbinado.Server.Handlers.RequestHandler (
requestHandler
@@ -1,159 +0,0 @@
-{-# OPTIONS -fglasgow-exts -fallow-overlapping-instances #-}
------------------------------------------------------------------------------
--- |
--- Module : Turbinado.SessionHandlers.GenericDB
--- Copyright : (c) Niklas Broberg 2006
--- License : BSD-style (see the file LICENSE.txt)
---
--- Maintainer : Niklas Broberg, d00nibro@dtek.chalmers.se
--- Stability : experimental
--- Portability : requires HaskellDB
---
--- A generic SessionHandler template for use with databases that are
--- supported by HaskellDB. To use it, write a session handler that imports
--- this module and provides the proper connect function. See also the DbSpec.hs
--- file to see how to set up the database proper.
------------------------------------------------------------------------------
-module Turbinado.SessionHandlers.GenericDB (
- mkSessionDB
- ) where
-
-import Database.HaskellDB
-import Database.HaskellDB.HDBRec (RecCons, RecNil)
-
-import Turbinado.SessionHandler (SessionId, Key, Value, Expires, SessionData, SessionItem)
-import qualified Turbinado.SessionHandler as SH
-
-import Turbinado.SessionHandlers.GenericDB.SessionDBInfo
-import Turbinado.SessionHandlers.GenericDB.SessionDBInfo.Sessions (sessions, sessionId, expires)
-import Turbinado.SessionHandlers.GenericDB.SessionDBInfo.SessionData (sessionData, datakey, value, dataExpires)
-
-import qualified Turbinado.SessionHandlers.GenericDB.SessionDBInfo.Sessions as S (SessionId, Expires)
-import qualified Turbinado.SessionHandlers.GenericDB.SessionDBInfo.SessionData as SD (sessionId, SessionId, DataKey, Value, DataExpires)
-
---import Turbinado.PrintDebug
-debugM e _ = return ()
-
-
-data SessionDB = SessionDB {
- dbconnect :: forall a . (Database -> IO a) -> IO a
- }
-
-instance SH.SessionHandler SessionDB where
- lookupData = lookupData
- insertNew = insertNew
- insertNewData = insertNewData
- updateExpires = updateExpires
- updateData = updateData
- deleteSession = deleteSession
- deleteData = deleteData
-
-----------------------------------------------------
--- Creating a SessionDB object
-
-mkSessionDB :: (forall a . (Database -> IO a) -> IO a) -> SessionDB
-mkSessionDB = SessionDB
-
-----------------------------------------------------
--- Lookup of session data
-
-lookupData :: SessionDB -> SessionId -> IO (Maybe SessionData)
-lookupData sdb sid = do
- debugM e $ "Performing lookup in DB for " ++ show sid ++ " ... "
- recs <- (dbconnect sdb)
- (\db -> do debugM e . show $ selectSId sid
- query db $ selectSId sid)
- debugM e "Done!"
- case recs of
- [] -> return Nothing
- rs@(r:_) -> do let exps = r!expires
- ds = map getData rs
- return $ Just (exps, ds)
- where getData r = let k = r!datakey
- v = r!value
- e = r!dataExpires
- in (k, (v,e))
-
-selectSId :: SessionId -> Query (Rel (
- RecCons S.SessionId (Expr SessionId) (
- RecCons S.Expires (Expr Expires) (
- RecCons SD.DataKey (Expr Key) (
- RecCons SD.Value (Expr Value) (
- RecCons SD.DataExpires (Expr Expires)
- RecNil ))))))
-selectSId sid = do
- ses <- table sessions
- dat <- table sessionData
- restrict (ses!sessionId .==. constant sid .&&. ses!sessionId .==. dat!SD.sessionId)
- project ( sessionId << ses!sessionId
- # expires << ses!expires
- # datakey << dat!datakey
- # value << dat!value
- # dataExpires << dat!dataExpires
- )
-
-----------------------------------------------------
--- New session
-
-insertNew :: SessionDB -> SessionId -> Expires -> IO ()
-insertNew sdb sid exps = (dbconnect sdb) $ insertSession sid exps
-
-insertSession :: SessionId -> Expires -> (Database -> IO ())
-insertSession sid exps = \db -> insert db sessions
- ( sessionId << constant sid
- # expires << constant exps )
-
-
-insertNewData :: SessionDB -> SessionId -> SessionItem -> IO ()
-insertNewData sdb sid dat = (dbconnect sdb) $ insertSessionData sid dat
-
-insertSessionData :: SessionId -> SessionItem -> (Database -> IO ())
-insertSessionData sid (k,(v,e)) = \db -> insert db sessionData
- ( SD.sessionId << constant sid
- # datakey << constant k
- # value << constant v
- # dataExpires << constant e )
-
-----------------------------------------------------
--- Update session
-
-updateExpires :: SessionDB -> SessionId -> Expires -> IO ()
-updateExpires sdb sid exps = (dbconnect sdb) $ updateExp sid exps
-
-updateExp :: SessionId -> Expires -> (Database -> IO ())
-updateExp sid exps = \db -> update db sessions
- (\r -> r!sessionId .==. constant sid)
- (\r -> expires << constant exps)
-
-updateData :: SessionDB -> SessionId -> (Key, (Value, Expires)) -> IO ()
-updateData sdb sid dat = (dbconnect sdb) $ updateSessionData sid dat
-
-updateSessionData :: SessionId -> (Key, (Value, Expires)) -> (Database -> IO ())
-updateSessionData sid (k,(v,e)) = \db -> update db sessionData
- (\r -> r!SD.sessionId .==. constant sid)
- (\r -> datakey << constant k # value << constant v # dataExpires << constant e)
-
-----------------------------------------------------
--- Delete session
-
-deleteSession :: SessionDB -> SessionId -> IO ()
-deleteSession sdb sid = (dbconnect sdb) $ deleteSess sid
-
-deleteSess :: SessionId -> (Database -> IO ())
-deleteSess sid = \db -> do
- delete db sessionData
- (\r -> r!SD.sessionId .==. constant sid)
- delete db sessions
- (\r -> r!sessionId .==. constant sid)
-
-deleteData :: SessionDB -> SessionId -> Key -> IO ()
-deleteData sdb sid k = (dbconnect sdb) $ deleteSessionData sid k
-
-deleteSessionData :: SessionId -> Key -> (Database -> IO ())
-deleteSessionData sid k = \db -> delete db sessionData
- (\r -> r!SD.sessionId .==. constant sid
- .&&. r!datakey .==. constant k)
-
-
-
--- main = lookupData (SessionDB psqlconnect) 1 >>= print
@@ -1,30 +0,0 @@
----------------------------------------------------------------------------
--- Generated by DB/Direct
----------------------------------------------------------------------------
-module Turbinado.SessionHandlers.GenericDB.SessionDBInfo where
-
-import Database.HaskellDB.DBLayout
-
-import qualified Turbinado.SessionHandlers.GenericDB.SessionDBInfo.Sessions
-import qualified Turbinado.SessionHandlers.GenericDB.SessionDBInfo.SessionData
-
---import Turbinado.Utils (sessionDBname)
-
-dbLayout :: String -> DBInfo
-dbLayout sessionDBname =
- DBInfo {dbname = sessionDBname,
- opts = DBOptions {useBString = False},
- tbls = [TInfo {tname = "Sessions",
- cols = [CInfo {cname = "sessionId",
- descr = (IntT, False)},
- CInfo {cname = "expires",
- descr = (UTCTimeT, True)}]},
- TInfo {tname = "SessionData",
- cols = [CInfo {cname = "sessionId",
- descr = (IntT, False)},
- CInfo {cname = "datakey",
- descr = (StringT, False)},
- CInfo {cname = "value",
- descr = (StringT, False)},
- CInfo {cname = "dataExpires",
- descr = (UTCTimeT, True)}]}]}
@@ -1,68 +0,0 @@
----------------------------------------------------------------------------
--- Generated by DB/Direct
----------------------------------------------------------------------------
-module Turbinado.SessionHandlers.GenericDB.SessionDBInfo.SessionData where
-
-import Database.HaskellDB.DBLayout
-
----------------------------------------------------------------------------
--- Table
----------------------------------------------------------------------------
-sessionData :: Table
- ((RecCons SessionId (Expr Int)
- (RecCons DataKey (Expr String)
- (RecCons Value (Expr String)
- (RecCons DataExpires (Expr (Maybe UTCTime)) RecNil)))))
-
-sessionData = baseTable "sessiondata" $
- hdbMakeEntry SessionId #
- hdbMakeEntry DataKey #
- hdbMakeEntry Value #
- hdbMakeEntry DataExpires
-
----------------------------------------------------------------------------
--- Fields
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--- SessionId Field
----------------------------------------------------------------------------
-
-data SessionId = SessionId
-
-instance FieldTag SessionId where fieldName _ = "sessionid"
-
-sessionId :: Attr SessionId Int
-sessionId = mkAttr SessionId
-
----------------------------------------------------------------------------
--- Key Field
----------------------------------------------------------------------------
-
-data DataKey = DataKey
-
-instance FieldTag DataKey where fieldName _ = "datakey"
-
-datakey :: Attr DataKey String
-datakey = mkAttr DataKey
-
----------------------------------------------------------------------------
--- Value Field
----------------------------------------------------------------------------
-
-data Value = Value
-
-instance FieldTag Value where fieldName _ = "value"
-
-value :: Attr Value String
-value = mkAttr Value
-
----------------------------------------------------------------------------
--- DataExpires Field
----------------------------------------------------------------------------
-
-data DataExpires = DataExpires
-
-instance FieldTag DataExpires where fieldName _ = "dataexpires"
-
-dataExpires :: Attr DataExpires (Maybe UTCTime)
-dataExpires = mkAttr DataExpires
@@ -1,42 +0,0 @@
----------------------------------------------------------------------------
--- Generated by DB/Direct
----------------------------------------------------------------------------
-module Turbinado.SessionHandlers.GenericDB.SessionDBInfo.Sessions where
-
-import Database.HaskellDB.DBLayout
-
----------------------------------------------------------------------------
--- Table
----------------------------------------------------------------------------
-sessions :: Table
- ((RecCons SessionId (Expr Int)
- (RecCons Expires (Expr (Maybe CalendarTime)) RecNil)))
-
-sessions = baseTable "sessions" $
- hdbMakeEntry SessionId #
- hdbMakeEntry Expires
-
----------------------------------------------------------------------------
--- Fields
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--- SessionId Field
----------------------------------------------------------------------------
-
-data SessionId = SessionId
-
-instance FieldTag SessionId where fieldName _ = "sessionid"
-
-sessionId :: Attr SessionId Int
-sessionId = mkAttr SessionId
-
----------------------------------------------------------------------------
--- Expires Field
----------------------------------------------------------------------------
-
-data Expires = Expires
-
-instance FieldTag Expires where fieldName _ = "expires"
-
-expires :: Attr Expires (Maybe CalendarTime)
-expires = mkAttr Expires
@@ -1,17 +0,0 @@
-module HSPR.SessionHandlers.PostgreSQL where
-
-import HSPR.SessionHandlers.GenericDB
-import Database.HaskellDB.HSQL.PostgreSQL
-
-
-sessionHandler = mkSessionDB connection
-
-connection = postgresqlConnect options
- where options = PostgreSQLOptions {
- server = "@DB_HOST@",
- db = sessionDBname,
- uid = "@DB_UID@",
- pwd = "@DB_PWD@"
- }
-
-sessionDBname = "@DB_NAME@"
Oops, something went wrong.

0 comments on commit 9a9af21

Please sign in to comment.