Mercurial > urweb
view 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 |
line wrap: on
line source
type fruit = int table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string } PRIMARY KEY Id, CONSTRAINT Nam UNIQUE Nam type order = int table order : { Id : order, Fruit : fruit, Qty : int, Code : int } PRIMARY KEY Id, CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id) (* Everyone may knows IDs and names. *) policy sendClient (SELECT fruit.Id, fruit.Nam FROM fruit) (* The weight is sensitive information; you must know the secret. *) policy sendClient (SELECT fruit.Weight, fruit.Secret FROM fruit WHERE known(fruit.Secret)) policy sendClient (SELECT order.Id, order.Fruit, order.Qty FROM order, fruit WHERE order.Fruit = fruit.Id AND order.Qty = 13) fun fname r = x <- queryX (SELECT fruit.Weight FROM fruit WHERE fruit.Nam = {[r.Nam]} AND fruit.Secret = {[r.Secret]} AND fruit.Weight <> 3.14 AND fruit.Weight < 100.0 AND fruit.Weight <= 200.1 AND fruit.Weight > 1.23 AND fruit.Weight >= 1.24) (fn r => <xml>Weight is {[r.Fruit.Weight]}</xml>); return <xml><body> {x} </body></xml> fun main () = x1 <- queryX (SELECT fruit.Id, fruit.Nam FROM fruit WHERE fruit.Nam = "apple") (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>); x2 <- queryX (SELECT fruit.Nam, order.Qty FROM fruit, order WHERE fruit.Id = order.Fruit AND order.Qty = 13) (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>); ro <- oneOrNoRows (SELECT fruit.Id, fruit.Nam FROM fruit); return <xml><body> <ul>{x1}</ul> <ul>{x2}</ul> {case ro of None => <xml>None</xml> | Some _ => <xml>Some</xml>} <form> Fruit name: <textbox{#Nam}/><br/> Secret: <textbox{#Secret}/><br/> <submit action={fname}/> </form> </body></xml>