︙ | | | ︙ | |
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
;;
;; New data format is only the <formdat> portion from above
;; (define-class <formdat> ()
;; (form-data
;; ))
(define (make-formdat:formdat)(vector (make-hash-table)))
(define-inline (formdat:formdat-get-data vec) (vector-ref vec 0))
(define-inline (formdat:formdat-set-data! vec val)(vector-set! vec 0 val))
(define (formdat:initialize self)
(formdat:formdat-set-data! self (make-hash-table)))
(define (formdat:get self key)
(hash-table-ref/default
(formdat:formdat-get-data self)
|
|
|
|
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
;;
;; New data format is only the <formdat> portion from above
;; (define-class <formdat> ()
;; (form-data
;; ))
(define (make-formdat:formdat)(vector (make-hash-table)))
(define (formdat:formdat-get-data vec) (vector-ref vec 0))
(define (formdat:formdat-set-data! vec val)(vector-set! vec 0 val))
(define (formdat:initialize self)
(formdat:formdat-set-data! self (make-hash-table)))
(define (formdat:get self key)
(hash-table-ref/default
(formdat:formdat-get-data self)
|
︙ | | | ︙ | |
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
|
(define formdat:delim-patt-rex (regexp "^\\-+[0-9]+\\-*$"))
;; returns a hash with entries for all forms - could well use a proplist?
(define (formdat:load-all)
(let ((request-method (get-environment-variable "REQUEST_METHOD")))
(if (and request-method
(string=? request-method "POST"))
(formdat:load-all-port (current-input-port)))))
;; (s:process-cgi-input (caaar dat))
(define (formdat:load-all-port inp)
(let* ((formdat (make-formdat:formdat))
(debugp #f))
;; (open-output-file (conc "/tmp/delme-" (current-user-id) ".log"))))
;; (write-string (read-string #f inp) #f debugp) ;; destroys all data!
|
|
>
|
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
|
(define formdat:delim-patt-rex (regexp "^\\-+[0-9]+\\-*$"))
;; returns a hash with entries for all forms - could well use a proplist?
(define (formdat:load-all)
(let ((request-method (get-environment-variable "REQUEST_METHOD")))
(if (and request-method
(string=? request-method "POST"))
(formdat:load-all-port (current-input-port))
(make-formdat:formdat))))
;; (s:process-cgi-input (caaar dat))
(define (formdat:load-all-port inp)
(let* ((formdat (make-formdat:formdat))
(debugp #f))
;; (open-output-file (conc "/tmp/delme-" (current-user-id) ".log"))))
;; (write-string (read-string #f inp) #f debugp) ;; destroys all data!
|
︙ | | | ︙ | |
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
|
;; (print "datstr: " datstr " munged: " munged)
(if (and (not (null? alldats))
(not (null? (car alldats)))
(not (null? (caar alldats))))
(formdat:load formdat (s:process-cgi-input (caaar alldats))))) ;; munged))
;; (format debugp "formdat : name: ~A content: ~A\n" name content)
(if debugp (close-output-port debugp))
formdat))))
#|
(define inp (open-input-file "tests/example.post.in"))
(define dat (read-string #f inp))
(define datstr (open-input-string dat))
|
>
|
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
|
;; (print "datstr: " datstr " munged: " munged)
(if (and (not (null? alldats))
(not (null? (car alldats)))
(not (null? (caar alldats))))
(formdat:load formdat (s:process-cgi-input (caaar alldats))))) ;; munged))
;; (format debugp "formdat : name: ~A content: ~A\n" name content)
(if debugp (close-output-port debugp))
;; (sdat-formdat-set! s:session formdat)
formdat))))
#|
(define inp (open-input-file "tests/example.post.in"))
(define dat (read-string #f inp))
(define datstr (open-input-string dat))
|
︙ | | | ︙ | |
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
|
(let* ((fp (open-input-file name))
(initargs (read fp)))
(close-input-port fp)
initargs))))
;; call the controller if it exists
;;
;; WARNING - this code needs a defence agains recursive calling!!!!!
;;
;; I suggest a limit of 100 calls. Plenty for allowing multiple instances
;; of a page inside another page.
;;
;; parts = 'both | 'control | 'view
;;
|
|
|
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
|
(let* ((fp (open-input-file name))
(initargs (read fp)))
(close-input-port fp)
initargs))))
;; call the controller if it exists
;;
;; WARNING - this code needs a defense agains recursive calling!!!!!
;;
;; I suggest a limit of 100 calls. Plenty for allowing multiple instances
;; of a page inside another page.
;;
;; parts = 'both | 'control | 'view
;;
|
︙ | | | ︙ | |
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
|
(car params)))
(tags (if (null? params)
'()
(cdr params)))
(formdat (sdat-formdat self))
(res (if (not formdat) #f
(if (or (string? key)(number? key)(symbol? key))
(if (and (vector? formdat)(eq? (vector-length formdat) 1)(hash-table? (vector-ref formdat 0)))
(formdat:get formdat key)
(begin
(session:log self "ERROR: formdat: " formdat " is not of class <formdat>")
#f))
(begin
(session:log self "ERROR: bad key " key)
#f)))))
|
|
>
>
|
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
|
(car params)))
(tags (if (null? params)
'()
(cdr params)))
(formdat (sdat-formdat self))
(res (if (not formdat) #f
(if (or (string? key)(number? key)(symbol? key))
(if (and (vector? formdat)
(eq? (vector-length formdat) 1)
(hash-table? (vector-ref formdat 0)))
(formdat:get formdat key)
(begin
(session:log self "ERROR: formdat: " formdat " is not of class <formdat>")
#f))
(begin
(session:log self "ERROR: bad key " key)
#f)))))
|
︙ | | | ︙ | |