91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
(define (sdat-set-curr-err! vec val)(vector-set! vec 27 val))
(define (sdat-set-log-port! vec val)(vector-set! vec 28 val))
(define (sdat-set-logfile! vec val)(vector-set! vec 29 val))
(define (sdat-set-seen-pages! vec val)(vector-set! vec 30 val))
(define (sdat-set-page-dir-style! vec val)(vector-set! vec 31 val))
(define (sdat-set-debugmode! vec val)(vector-set! vec 32 val))
;; (define-class <session> ()
;; (dbtype ;; 'pg or 'sqlite3
;; dbinit
;; conn
;; params ;; params from the key=val&key1=val2 string
;; path-params ;; remaining params from the path
;; session-key
;; session-id
;; domain
;; toppage ;; defaults to "index" - override in .stml.config if desired
;; page ;; the page name - defaults to home
;; curr-page ;; the current page being evaluated
;; content-type ;; the default content type is text/html, override to deliver other stuff
;; page-type ;; use in conjunction with content-type to deliver other payloads
;; sroot
;; twikidir ;; location for twikis - needs to be fully writable by web server
;; pagedat
;; alt-page-dat
;; pagevars ;; session vars specific to this page
;; pagevars-before
;; sessionvars ;; session vars visible to all pages
;; sessionvars-before
;; globalvars ;; global vars visible to all sessions
;; globalvars-before
;; logpt
;; formdat
;; request-method
;; session-cookie
;; curr-err
;; 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")
|
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
(define (sdat-set-curr-err! vec val)(vector-set! vec 27 val))
(define (sdat-set-log-port! vec val)(vector-set! vec 28 val))
(define (sdat-set-logfile! vec val)(vector-set! vec 29 val))
(define (sdat-set-seen-pages! vec val)(vector-set! vec 30 val))
(define (sdat-set-page-dir-style! vec val)(vector-set! vec 31 val))
(define (sdat-set-debugmode! vec val)(vector-set! vec 32 val))
;; The global session
(define s:session (make-sdat))
;; 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")
|
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
(define (session:page-get self key)
(hash-table-ref/default (sdat-get-pagevars self) key #f))
;; get session vars for a specified page
;;
(define (session:get self page key)
(let ((ht (session:get-page-hash self page)))
(hash-table-ref/default ht key #f)))
;; delete a session var for a specified page
;;
(define (session:del! self page key)
(let ((ht (session:get-page-hash self page)))
(hash-table-delete! ht key)))
;; get ALL keys for this page and store in the session pagevars hash
;;
(define (session:get-vars self)
(let ((session-id (sdat-get-session-id self)))
(if (not session-id)
(err:log "ERROR: No session id in session object! session:get-vars")
|
|
|
|
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
(define (session:page-get self key)
(hash-table-ref/default (sdat-get-pagevars self) key #f))
;; get session vars for a specified page
;;
(define (session:get self page key)
(let ((ht (session:get-page-hash self page)))
(hash-table-ref/default ht (s:any->string key) #f)))
;; delete a session var for a specified page
;;
(define (session:del! self page key)
(let ((ht (session:get-page-hash self page)))
(hash-table-delete! ht (s:any->string key))))
;; get ALL keys for this page and store in the session pagevars hash
;;
(define (session:get-vars self)
(let ((session-id (sdat-get-session-id self)))
(if (not session-id)
(err:log "ERROR: No session id in session object! session:get-vars")
|