annotate tests/policy.ur @ 1739:c414850f206f
Add support for -boot flag, which allows in-tree execution of Ur/Web
The boot flag rewrites most hardcoded paths to point to the build
directory, and also forces static compilation. This is convenient
for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web.
The following changes were made:
* Header files were moved to include/urweb instead of include;
this lets FFI users point their C_INCLUDE_PATH at this directory
at write <urweb/urweb.h>. For internal Ur/Web executables,
we simply pass -I$PATH/include/urweb as normal.
* Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript
source files, while LIB is compiled products from libtool. For
in-tree compilation these live in different places.
* No longer reference Config for paths; instead use Settings; these
settings can be changed dynamically by Compiler.enableBoot ()
(TODO: add a disableBoot function.)
* config.h is now generated directly in include/urweb/config.h,
for consistency's sake (especially since it gets installed
along with the rest of the headers!)
* All of the autotools build products got updated.
* The linkStatic field in protocols now only contains the name of the
build product, and not the absolute path.
Future users have to be careful not to reference the Settings files
to early, lest they get an old version (this was the source of two
bugs during development of this patch.)
author |
Edward Z. Yang <ezyang@mit.edu> |
date |
Wed, 02 May 2012 17:17:57 -0400 |
parents |
d5ecceb7d1a1 |
children |
|
rev |
line source |
adamc@1204
|
1 type fruit = int
|
adamc@1204
|
2 table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string }
|
adamc@1204
|
3 PRIMARY KEY Id,
|
adamc@1204
|
4 CONSTRAINT Nam UNIQUE Nam
|
adamc@1204
|
5
|
adamc@1204
|
6 type order = int
|
adamc@1204
|
7 table order : { Id : order, Fruit : fruit, Qty : int, Code : int }
|
adamc@1204
|
8 PRIMARY KEY Id,
|
adamc@1204
|
9 CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id)
|
adamc@1199
|
10
|
adamc@1207
|
11 (* Everyone may knows IDs and names. *)
|
adamc@1236
|
12 policy sendClient (SELECT fruit.Id, fruit.Nam
|
adamc@1214
|
13 FROM fruit)
|
adamc@1207
|
14
|
adamc@1207
|
15 (* The weight is sensitive information; you must know the secret. *)
|
adamc@1214
|
16 policy sendClient (SELECT fruit.Weight, fruit.Secret
|
adamc@1214
|
17 FROM fruit
|
adamc@1214
|
18 WHERE known(fruit.Secret))
|
adamc@1207
|
19
|
adamc@1214
|
20 policy sendClient (SELECT order.Id, order.Fruit, order.Qty
|
adamc@1214
|
21 FROM order, fruit
|
adamc@1214
|
22 WHERE order.Fruit = fruit.Id
|
adamc@1214
|
23 AND order.Qty = 13)
|
adamc@1200
|
24
|
adamc@1207
|
25 fun fname r =
|
adamc@1207
|
26 x <- queryX (SELECT fruit.Weight
|
adamc@1207
|
27 FROM fruit
|
adamc@1207
|
28 WHERE fruit.Nam = {[r.Nam]}
|
adamc@1210
|
29 AND fruit.Secret = {[r.Secret]}
|
adamc@1210
|
30 AND fruit.Weight <> 3.14
|
adamc@1210
|
31 AND fruit.Weight < 100.0
|
adamc@1210
|
32 AND fruit.Weight <= 200.1
|
adamc@1210
|
33 AND fruit.Weight > 1.23
|
adamc@1210
|
34 AND fruit.Weight >= 1.24)
|
adamc@1207
|
35 (fn r => <xml>Weight is {[r.Fruit.Weight]}</xml>);
|
adamc@1207
|
36
|
adamc@1207
|
37 return <xml><body>
|
adamc@1207
|
38 {x}
|
adamc@1207
|
39 </body></xml>
|
adamc@1207
|
40
|
adamc@1200
|
41 fun main () =
|
adamc@1204
|
42 x1 <- queryX (SELECT fruit.Id, fruit.Nam
|
adamc@1209
|
43 FROM fruit
|
adamc@1210
|
44 WHERE fruit.Nam = "apple")
|
adamc@1204
|
45 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);
|
adamc@1204
|
46
|
adamc@1204
|
47 x2 <- queryX (SELECT fruit.Nam, order.Qty
|
adamc@1204
|
48 FROM fruit, order
|
adamc@1206
|
49 WHERE fruit.Id = order.Fruit
|
adamc@1206
|
50 AND order.Qty = 13)
|
adamc@1204
|
51 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);
|
adamc@1200
|
52
|
adamc@1228
|
53 ro <- oneOrNoRows (SELECT fruit.Id, fruit.Nam
|
adamc@1228
|
54 FROM fruit);
|
adamc@1228
|
55
|
adamc@1200
|
56 return <xml><body>
|
adamc@1204
|
57 <ul>{x1}</ul>
|
adamc@1210
|
58
|
adamc@1204
|
59 <ul>{x2}</ul>
|
adamc@1207
|
60
|
adamc@1228
|
61 {case ro of
|
adamc@1228
|
62 None => <xml>None</xml>
|
adamc@1228
|
63 | Some _ => <xml>Some</xml>}
|
adamc@1228
|
64
|
adamc@1207
|
65 <form>
|
adamc@1207
|
66 Fruit name: <textbox{#Nam}/><br/>
|
adamc@1207
|
67 Secret: <textbox{#Secret}/><br/>
|
adamc@1207
|
68 <submit action={fname}/>
|
adamc@1207
|
69 </form>
|
adamc@1200
|
70 </body></xml>
|