Overview
Comment:Added s:get-inp which does s:get-input falling back to s:get-param if no input var exists
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 962faddbede93863aa31b1cd485d557ac263bcf2
User & Date: matt on 2017-03-11 12:03:31
Other Links: manifest | tags
Context
2017-03-13
06:30
Added obfuscated set/get check-in: 544afe46f9 user: matt tags: trunk
2017-03-11
12:03
Added s:get-inp which does s:get-input falling back to s:get-param if no input var exists check-in: 962faddbed user: matt tags: trunk
2017-03-07
20:36
Minor cleanup of example in howto.txt and changed s:local-set to s:lset check-in: fd0492638e user: matt tags: trunk
Changes

Modified doc/howto.txt from [a914119ee4] to [2ccf521fee].

16
17
18
19
20
21
22







23
24
25
26
27
28
29
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







+
+
+
+
+
+
+







http://the.domain.com/pagename/p1/p2/p3?param1=value1

(s:get-page-params) => '("p1" "p2")

(s:get-param 'param1) => "value1"
(s:get-param 'param1 'number) => number or #f 

NOTE: it is often practical to use the generic (s:get-inp ...) which
      will first look for the POST input variable and then fall back
      to the GET param. This allows one to switch back and forth
      between GET and POST during development without changing the code.

(s:get-inp 'param1)  ;; trys to find input by name of param1, followed by trying get-param

Create a link.
~~~~~~~~~~~~~~

(s:a name 'href 
    (s:link-to "pagename/blah" ""))

Call current page with new param

Modified session.scm from [107551e843] to [2e2e2318d1].

691
692
693
694
695
696
697
698

699
700
701
702
703
704
705
691
692
693
694
695
696
697

698
699
700
701
702
703
704
705







-
+







	(let ((newresult (cons (string-append (s:any->string key) "=" (s:any->string val))
			       result)))
	  (if (< (length tail) 1) ;; true if done
	      (string-intersperse newresult "&")
	      (loop (car tail)(cadr tail)(cddr tail) newresult))))))

(define (session:link-to self page params)
  (let* ((server    (if (get-environment-variable "HTTP_HOST")
  (let* ((server    (or (get-environment-variable "HTTPS_HOST") ;; Assuming HTTPS_HOST is only set if available
			(get-environment-variable "HTTP_HOST")
			(get-environment-variable "SERVER_NAME")))
         (force-script  (sdat-get-script self))
	 (script (or force-script
                     (let ((script-name (string-split (get-environment-variable "SCRIPT_NAME") "/")))
                       (if (> (length script-name) 1)
                           (string-append (car script-name) "/" (cadr script-name))
750
751
752
753
754
755
756


757
758
759
760
761
762
763
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765







+
+







			  "\r")
			 "\\r")
			res)) ;; should return #f if not a string and can't escape it?
      (else      (if (string? res)
		     (s:html-filter->string res '())
		     res)))))

;; params are stored as list of key=val
;;
(define (session:get-param self key type-params)
  ;; (session:log s:session "params=" (slot-ref s:session 'params))
  (let* ((params (sdat-get-params self))
	 (res    (session:get-param-from params key)))
    (session:apply-type-preference res type-params)))

;; This one will get the first value found regardless of form

Modified setup.scm from [f14081cc23] to [4c7036352c].

105
106
107
108
109
110
111






112
113
114
115
116
117
118
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124







+
+
+
+
+
+







;;
(define (s:get-input key . params)
  (session:get-input s:session key params))

(define (s:get-input-keys)
  (session:get-input-keys s:session))

;; get-input else, get-param else #f
;;
(define (s:get-inp key . params)
  (or (apply s:get-input key params)
      (apply s:get-param key params)))

(define (s:load-model model)
  (session:load-model s:session model))

(define (s:model-path model)
  (session:model-path s:session model))

;; share data between pages calls. NOTE: This is not persistent