172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
+
+
+
|
(let ((dbtype (sdat-get-dbtype self))
(debugmode (sdat-get-debugmode self))
(dbinit (eval (sdat-get-dbinit self)))
(dbexists #f))
(let ((dbfname (alist-ref 'dbname dbinit)))
(if debugmode (session:log self "session:setup dbfname=" dbfname ", dbtype=" dbtype ", dbinit=" dbinit))
(if (eq? dbtype 'sqlite3)
;; The 'auto method will distribute dbs across the disk using hash
;; of user host and user. TODO
;; (if (eq? dbfname 'auto) ;; This is the auto assignment of a db based on hash of IP
(let ((dbpath (pathname-directory dbfname))) ;; do a couple sanity checks here to make setting up easier
(if debugmode (session:log self "INFO: setting up for sqlite3 db access to " dbfname))
(if (not (file-write-access? dbpath))
(session:log self "WARNING: Cannot write to " dbpath)
(if debugmode (session:log self "INFO: " dbpath " is writeable")))
(if (file-exists? dbfname)
(begin
|
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
((stored)
((eval (string->symbol (conc "pages:" page)))
self ;; the session
(sdat-get-conn self) ;; the db connection
(sdat-get-shared-hash self) ;; a shared hash table for passing data to/from page calls
))
((flat)
(load (conc dir page ".so"))
((eval (string->symbol (conc "pages:" page)))
self ;; the session
(sdat-get-conn self) ;; the db connection
(sdat-get-shared-hash self) ;; a shared hash table for passing data to/from page calls
))
(let* ((so-file (conc dir page ".so"))
(scm-file (conc dir page ".scm"))
(src-file (or (file-exists? so-file)
(file-exists? scm-file))))
(if src-file
(begin
(load src-file)
((eval (string->symbol (conc "pages:" page)))
self ;; the session
(sdat-get-conn self) ;; the db connection
(sdat-get-shared-hash self) ;; a shared hash table for passing data to/from page calls
))
(list "<p>Page not found " page " </p>"))))
;; first the control
;; (let ((control-file (conc "pages/" page "_ctrl.scm"))
;; (view-file (conc "pages/" page "_view.scm")))
;; (if (and (file-exists? control-file)
;; (not (eq? parts 'view)))
;; (begin
;; (session:set-called! self page)
|