Overview
Comment: | 95% ported to chicken-scheme v4.7 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | move-to-ck4.7.x |
Files: | files | file ages | folders |
SHA1: |
361599ef76010491ead5f07eed3209b3 |
User & Date: | matt on 2011-10-02 23:35:43 |
Other Links: | branch diff | manifest | tags |
Context
2011-10-02
| ||
23:50 | 98% ported to chicken-scheme v4.7 check-in: 414475a853 user: matt tags: move-to-ck4.7.x | |
23:35 | 95% ported to chicken-scheme v4.7 check-in: 361599ef76 user: matt tags: move-to-ck4.7.x | |
22:22 | 90% ported to chicken-scheme v4.7.0 check-in: 45412597aa user: matt tags: move-to-ck4.7.x | |
Changes
Modified Makefile from [90551885a6] to [16c485aa22].
︙ | ︙ | |||
18 19 20 21 22 23 24 | install : $(TARGDIR)/stmlrun $(LOGDIR) $(MODULES) all : $(SOFILES) stmlrun : stmlrun.scm formdat.scm misc-stml.scm session.scm stml.scm \ setup.scm html-filter.scm requirements.scm keystore.scm \ | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | install : $(TARGDIR)/stmlrun $(LOGDIR) $(MODULES) all : $(SOFILES) stmlrun : stmlrun.scm formdat.scm misc-stml.scm session.scm stml.scm \ setup.scm html-filter.scm requirements.scm keystore.scm \ cookie.scm sqltbl.scm csc stmlrun.scm $(TARGDIR)/stmlrun : stmlrun cp stmlrun $(TARGDIR) chmod a+rx $(TARGDIR)/stmlrun |
︙ | ︙ |
Modified session.scm from [95d0573588] to [e1ef9f0955].
︙ | ︙ | |||
123 124 125 126 127 128 129 | ;; log-port ;; logfile ;; seen-pages ;; page-dir-style ;; #t = new style, #f = old style ;; debugmode)) ;; SPLIT INTO STRAIGHT FORWARD INIT AND COMPLEX INIT | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | ;; log-port ;; logfile ;; seen-pages ;; page-dir-style ;; #t = new style, #f = old style ;; debugmode)) ;; SPLIT INTO STRAIGHT FORWARD INIT AND COMPLEX INIT (define (session:initialize self) (sdat-set-dbtype! self 'pg) (sdat-set-page! self "home") ;; these are defaults (sdat-set-curr-page! self "home") (sdat-set-content-type! self "Content-type: text/html; charset=iso-8859-1\n\n") (sdat-set-page-type! self 'html) (sdat-set-toppage! self "index") (sdat-set-params! self '()) ;; |
︙ | ︙ | |||
303 304 305 306 307 308 309 | "DELETE FROM session_vars WHERE session_id=?;" "DELETE FROM sessions WHERE id=?;" "COMMIT;")) (conn (sdat-get-conn self))) (if session-id (begin (dbi:exec conn qry session-id session-id) | | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | "DELETE FROM session_vars WHERE session_id=?;" "DELETE FROM sessions WHERE id=?;" "COMMIT;")) (conn (sdat-get-conn self))) (if session-id (begin (dbi:exec conn qry session-id session-id) (session:initialize self) (session:setup self))) (not (session:get-session-id self session-key)))) ;; (define (session:delete-session self session-key) ;; (let ((session-id (session:get-session-id self session-key)) ;; (queries (list "BEGIN;" ;; "DELETE FROM session_vars WHERE session_id=?;" |
︙ | ︙ |
Modified setup.scm from [c6717dd49d] to [0bb860ef3f].
1 2 3 4 5 6 7 8 9 10 11 | ;; Copyright 2007-2008, Matthew Welland. ;; ;; This program is made available under the GNU GPL version 2.0 or ;; greater. See the accompanying file COPYING for details. ;; ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;; (define s:session (make-sdat)) | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ;; Copyright 2007-2008, Matthew Welland. ;; ;; This program is made available under the GNU GPL version 2.0 or ;; greater. See the accompanying file COPYING for details. ;; ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;; (define s:session (make-sdat)) (session:initialize s:session) ;; use this for getting data from page to page when scope and evals ;; get in the way (define s:local-vars (make-hash-table)) (define (s:local-set! k v) (hash-table-set! s:local-vars k v)) |
︙ | ︙ |
Modified sqltbl.scm from [b05f4ba4b6] to [9b13c4cca2].
1 2 3 4 5 | ;; Copyright 2007-2008, Matthew Welland. Kiatoa.com All rights reserved. ;; ;; DON'T USE THIS!!!! It was a bad idea :-( | < < | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | ;; Copyright 2007-2008, Matthew Welland. Kiatoa.com All rights reserved. ;; ;; DON'T USE THIS!!!! It was a bad idea :-( ;; (require-extension tinyclos) ;; (define-class <sqltbl> () ;; (rows ;; fields ;; list of field ;; fields-hash ;; hash of fields -> number ;; query ;; query string using ?'s ;; query-params ;; list of params for the query ;; conn ;; connection to db ;; num-rows ;; whatever ;; curr-row-ptr ;; number of the current row ;; curr-row ;; the current row vector (?? do we really want this ??) ;; )) (define (make-sqltbl:tbl)(make-vector 9)) (define-inline (sqltbl:tbl-get-rows vec) (vector-ref vec 0)) (define-inline (sqltbl:tbl-get-fields vec) (vector-ref vec 1)) (define-inline (sqltbl:tbl-get-fields-hash vec) (vector-ref vec 2)) (define-inline (sqltbl:tbl-get-query vec) (vector-ref vec 3)) (define-inline (sqltbl:tbl-get-query-params vec) (vector-ref vec 4)) (define-inline (sqltbl:tbl-get-conn vec) (vector-ref vec 5)) (define-inline (sqltbl:tbl-get-num-rows vec) (vector-ref vec 6)) (define-inline (sqltbl:tbl-get-curr-row-ptr vec) (vector-ref vec 7)) (define-inline (sqltbl:tbl-get-curr-row vec) (vector-ref vec 8)) (define-inline (sqltbl:tbl-set-rows! vec val)(vector-set! vec 0 val)) (define-inline (sqltbl:tbl-set-fields! vec val)(vector-set! vec 1 val)) (define-inline (sqltbl:tbl-set-fields-hash! vec val)(vector-set! vec 2 val)) (define-inline (sqltbl:tbl-set-query! vec val)(vector-set! vec 3 val)) (define-inline (sqltbl:tbl-set-query-params! vec val)(vector-set! vec 4 val)) (define-inline (sqltbl:tbl-set-conn! vec val)(vector-set! vec 5 val)) (define-inline (sqltbl:tbl-set-num-rows! vec val)(vector-set! vec 6 val)) (define-inline (sqltbl:tbl-set-curr-row-ptr! vec val)(vector-set! vec 7 val)) (define-inline (sqltbl:tbl-set-curr-row! vec val)(vector-set! vec 8 val)) (define (session:initialize self);; initargs) (sqltbl:tbl-set-num-rows! self 0) (sqltbl:tbl-set-curr-row-ptr! self 0) (sqltbl:tbl-set-fields! self '()) (sqltbl:tbl-set-fields-hash! self (make-hash-table))) ;; (initialize-slots self initargs)) ;; (if (> (length (sqltbl:tbl-get-rows self) 0)) ;; (sqltbl:tbl-set-curr-row! self (car rows)))) (define (sqltbl:next-row self) (let ((curr-row-ptr (+ (sqltbl:tbl-get-curr-row-ptr self) 1)) (num-rows (sqltbl:tbl-get-num-rows self)) (rows (sqltbl:tbl-get-rows self))) (if (> curr-row-prt (sqltbl:tbl-get-num-rows self)) #f ;; there is no next row (let ((new-curr-row (list-ref rows curr-row-ptr))) (sqltbl:tbl-set-curr-row! self new-curr-row) (sqltbl:tbl-set-curr-row-prt! self curr-row-prt) new-curr-row)))) ;; run the query and fill the rows list (define (sqltbl:run-query self . params) (let* ((query (sqltbl:tbl-get-query self)) (fields (sqltbl:tbl-get-fields self)) (rows (let ((result '()) (actual-query (apply s:sqlparam query fields params))) ;; (s:log "actual-query=" actual-query) (dbi:for-each-row (lambda (tuple) (set! result (cons tuple result))) (sqltbl:tbl-get-conn self) actual-query) (sqltbl:tbl-set-query-params! self params) (sqltbl:tbl-set-num-rows! self (length result)) (sqltbl:setup-fields self) ;; update the fields lookup hash (reverse result)))) (sqltbl:tbl-set-rows! self rows) (if (not (null? rows)) (sqltbl:tbl-set-curr-row! self (car rows))) (sqltbl:tbl-set-curr-row-ptr! self 0) rows)) (define (sqltbl:setup-fields self) (let ((fields-hash (sqltbl:tbl-get-fields-hash self)) (fields-list (sqltbl:tbl-get-fields self))) (let loop ((head (car fields-list)) (tail (cdr fields-list)) (fnum 0)) (hash-table-set! fields-hash head fnum) (if (null? tail) fnum (loop (car tail)(cdr tail)(+ fnum 1)))))) ;; get a value from the current row (define (sqltbl:get-field-value-curr self field) (let ((curr-row (sqltbl:tbl-get-curr-row self)) (field-num (hash-table-ref/default (sqltbl:tbl-get-fields-hash self) field #f))) (if field-num (vector-ref curr-row field-num) #f))) ;; not found -> #f (define (sqltbl:vector->hash self vec) (let ((h (make-hash-table)) (fields (sqltbl:tbl-get-fields self))) (do ((i 0 (+ i 1))) ((>= i (length fields))) (hash-table-set! h (list-ref fields i)(vector-ref vec i))) h)) ;; runs proc on each row and returns the resulting list (define (sqltbl:map self proc) (map (lambda (row) (proc (sqltbl:vector->hash self row))) (sqltbl:tbl-get-rows self))) |
Modified stmlrun.scm from [cf9034b401] to [b64d7c8a58].
︙ | ︙ | |||
33 34 35 36 37 38 39 | ;; (s:log "HTTP_COOKIE" (get-environment-variable "HTTP_COOKIE")) ;; (s:log "stdin-dat=" (slot-ref s:session 'stdin-dat)) (s:validate-inputs) (session:run-actions s:session) | | | | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ;; (s:log "HTTP_COOKIE" (get-environment-variable "HTTP_COOKIE")) ;; (s:log "stdin-dat=" (slot-ref s:session 'stdin-dat)) (s:validate-inputs) (session:run-actions s:session) (sdat-set-pagedat! s:session (append (sdat-get-pagedat s:session) (s:call (sdat-get-toppage s:session)))) (if (eq? (sdat-get-page-type s:session) 'html) ;; default is html. (session:cgi-out s:session) (session:alt-out s:session)) (session:save-vars s:session) (session:close s:session) |
︙ | ︙ |