Anonymous avatar Anonymous committed 4b2bbaa

Doing some experiments in wings.lsp

Comments (0)

Files changed (2)

example-site/dragonfly-framework/config.lsp

 (constant 'STATIC_TRIGGER_EXTENSIONS '(".html"))
 ; If the path does not have one of the STATIC_TRIGGER_EXTENSIONS, then the
 ; handler will attempt to modify the URL (not including the GET params) using
-; the STATIC_TRANSFORMATIONS, which is simply a list of possible modifictiations
+; the STATIC_TRANSFORMATIONS, which is simply a list of possible modifications
 ; to the path, which is bound to the '_' symbol). If one of them matches a file,
 ; the entire route matches and the file is passed through the template evaluator,
 ; otherwise it will not match and defer to the other handler(s).

example-site/resources/wings.lsp

 	)
 )
 
+; findWing is an experiment to check if we really need a database abstraction layer
+; my thoughts:
+; define the resource functions like findWing and implement the necessary db connection in it
+; common types of functions are findAll (SELECT * FROM _ WHERE 1), findOne (SELECT * FROM _ WHERE id = _)
+; GET /findWing/1 would do something like SELECT * FROM wings where ID = 1
+; GET /findAllWings would do something like SELECT * FROM wings where 1
+;
+; - Marc
+;
+
+(define (findWing id response-format)
+
+(DF:activate-plugin "sqlite3")
+
+; unfortunately in this situation we can't use NL's default values to do this for us...
+(if-not id (set 'id 0))
+
+; uh-oh! No range checking on 'resource-id' ...
+(if (= response-format "json")
+	(begin
+		(Response:content-type Response:json-type)
+		(print (Json:lisp->json (my-data id)))
+	)
+	(begin
+		
+		(Response:content-type Response:text-type)
+		(sql3:open "../databases/main.sqlite")
+		;(set 'query (string "SELECT * FROM entries WHERE id='"id"'"))
+		(set 'query (string "SELECT * FROM entries WHERE 1"))
+		(print query "\r\n")
+		(print (sql3:sql query))
+		; hmm...doesn't return nil, maybe the path to db is wrong
+		; there is a table entries - i know that!
+	)
+)
+
+)
+
 (context MAIN)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.