Mercurial > urweb
comparison tests/policy2.ur @ 1254:935a981f4380
Merge
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 06 May 2010 13:57:01 -0400 |
parents | d5ecceb7d1a1 |
children |
comparison
equal
deleted
inserted
replaced
1198:b52929351402 | 1254:935a981f4380 |
---|---|
1 type fruit = int | |
2 table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string } | |
3 PRIMARY KEY Id, | |
4 CONSTRAINT Nam UNIQUE Nam | |
5 | |
6 (* Everyone may knows IDs and names. *) | |
7 policy sendClient (SELECT fruit.Id, fruit.Nam | |
8 FROM fruit) | |
9 | |
10 (* The weight is sensitive information; you must know the secret. *) | |
11 policy sendClient (SELECT fruit.Weight, fruit.Secret | |
12 FROM fruit | |
13 WHERE known(fruit.Secret)) | |
14 | |
15 fun main () = | |
16 x1 <- queryX (SELECT fruit.Id, fruit.Nam | |
17 FROM fruit | |
18 WHERE fruit.Nam = "apple") | |
19 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>); | |
20 return <xml><body> | |
21 <ul>{x1}</ul> | |
22 </body></xml> |