Index: examples/python_tests/fruits_rt2/README
===================================================================
--- examples/python_tests/fruits_rt2/README	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/fruits_rt2/README	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,3 +1,2 @@
-#!/bin/sh
 #
 # This demonstrates assigning objects to object sets (osets) based on their
@@ -9,5 +8,5 @@
 # Credential 1 lays out Mary's policy - she will eat fruits that cost less that
 # or equal to 2.00.  Bob will eat fruits that cost between 1.00 and 5.00, as
-# laid out in Credential 2.  Strictly speaking Bob and Mary's ruls apply to
+# laid out in Credential 2.  Strictly speaking Bob and Mary's rules apply to
 # prices assigned by Ralphs.  Credentials 3-6 are Ralph's price assignments:
 # 
@@ -15,97 +14,32 @@
 # apple               1.50       3
 # kiwi                1.50       4
-# black rsaberry      2.50       5
+# black rasberry      2.50       5
 # navel ornage        0.50       6
 #
-# The attached ./run_query file proves that Mary will eat a naval orange and a kiwi,
+# The query.py file proves that Mary will eat a naval orange and a kiwi,
 # and that Bob will not eat a navel orange (too cheap).  It also proves a apple
 # is priced at 1.50 and that it cannot prove that a green apple is priced at
 # 1.50 (we don't know anything about green apples).
 
-# fruits_rt2_typed
+# fruits_rt2
 
-# mary.what2eat<-?-navel orange  good
-# mary.what2eat<-?-kiwi  good
-# bob.what2eat<-?-navel orange  bad
-# ralphs.fruitprice(1.50)<-?-apple   good
-# ralphs.fruitprice(1.50)<-?-green apple   bad
-
-creddy --generate --cn Mary
-creddy --generate --cn Bob
-creddy --generate --cn Ralphs
-
-mary_keyid=`creddy --keyid --cert Mary_ID.pem`
-bob_keyid=`creddy --keyid --cert Bob_ID.pem`
-ralphs_keyid=`creddy --keyid --cert Ralphs_ID.pem`
-
-fruitprice_qP="fruitprice([float:?P:[..2.00]])"
-fruitprice_qP_2="fruitprice([float:?P:[1.00..5.00]])"
-
+# Credential 1
 # [keyid:mary].oset:what2eat 
 #      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
-# Credential 1
-creddy --attribute \
-       --issuer Mary_ID.pem --key Mary_private.pem --oset "what2eat" \
-       --subject-cert Ralphs_ID.pem --subject-oset "$fruitprice_qP" \
-       --out mary_what2eat__ralphs_fruitprice_qP_attr.der
 
+# Credential 2
 # [keyid:bob].oset:what2eat 
 #      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
-# Credential 2
-creddy --attribute \
-       --issuer Bob_ID.pem --key Bob_private.pem --oset "what2eat" \
-       --subject-cert Ralphs_ID.pem --subject-oset "$fruitprice_qP_2" \
-       --out bob_what2eat__ralphs_fruitprice_qP_2_attr.der
 
+# Credential 3
 # [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
-# Credential 3
-creddy --attribute \
-        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
-        --oset "fruitprice([float:1.50])" \
-        --subject-obj "[string:'apple']" \
-        --out Ralphs_fruitprice__apple_attr.der
 
+# Credential 4
 # [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'kiwi']
-# Credential 4
-creddy --attribute \
-        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
-        --oset "fruitprice([float:1.50])" \
-        --subject-obj "[string:'kiwi']" \
-        --out Ralphs_fruitprice__kiwi_attr.der
 
+# Credential 5
+# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black rasberry']
 
-# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black rasberry']
-# Credential 5
-creddy --attribute \
-        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
-        --oset "fruitprice([float:2.50])" \
-        --subject-obj "[string:'black rasberry']" \
-        --out Ralphs_fruitprice__black_rasberry_attr.der
+# Credential 6
+# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
 
-# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
-# Credential 6
-creddy --attribute \
-        --issuer Ralphs_ID.pem --key Ralphs_private.pem \
-        --oset "fruitprice([float:0.50])" \
-        --subject-obj "[string:'navel orange']" \
-        --out Ralphs_fruitprice__navel_orange_attr.der
-
-#####################################################################
-# mary.what2eat <- ralphs.fruitsprice(?P:[..2.00])
-# [keyid:mary].oset:what2eat 
-#      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
-#
-# bob.what2eat <- ralphs.fruitsprice(?P:[1.00..5.00])
-# [keyid:bob].oset:what2eat 
-#      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
-# 
-# ralphs.fruitprice(1.50)<-apple
-# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
-#
-# ralphs.fruitprice(2.50)<-black rasberry
-# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black rasberry']
-#
-# ralphs.fruitprice(0.50)<-navel orange
-# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
-# 
-
Index: examples/python_tests/fruits_rt2/attr.py
===================================================================
--- examples/python_tests/fruits_rt2/attr.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/fruits_rt2/attr.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,4 +2,7 @@
 
 """
+See README in this directory for the semantics of the example.  This file
+constructs the credentials described and puts copies into this directory
+
 cmd1:env keystore=`pwd` ./attr.py 
 """
@@ -8,10 +11,12 @@
 import ABAC
 
-keystore=os.environ["keystore"]
-
 ctxt = ABAC.Context()
 print "ABAC version %s" % ctxt.version()
 
-ctxt.load_directory(keystore)
+# Keystore is the directory containing the principal credentials.
+# Load existing principals and/or policy credentials
+if (os.environ.has_key("keystore")) :
+    keystore=os.environ["keystore"]
+    ctxt.load_directory(keystore)
 
 out = ctxt.context_principals()
@@ -27,4 +32,5 @@
 print "\n"
 
+# retrieve principals' keyid value from local credential files
 ralphsID=ABAC.ID("Ralphs_ID.pem");
 ralphsID.id_load_privkey_file("Ralphs_private.pem");
@@ -40,17 +46,32 @@
 
 ################################################
+# Credential 1, what kind of fruit Mary would eat. Anything not costing more
+#               than 2 dollars
 # [keyid:mary].oset:what2eat
 #      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
-# [keyid:alpha].role:access([string:'Read'],[urn:'file//fileB']) <- [keyid:bob]
 head = ABAC.Oset(mary,"what2eat")
+
+# initialize a float range constraint
 cond=ABAC.Constraint("float")
+
+# add the upper max to the range, and only the max
 cond.constraint_add_float_max(2.00)
+
+# create the data term with the constraint
 param=ABAC.DataTerm("float", "P", cond)
 tail = ABAC.Oset(ralphs,"fruitprice")
 tail.oset_add_data_term(param)
+
+# compose the attribute policy
 attr=ABAC.Attribute(head, 1800)
 attr.attribute_add_tail(tail)
+
+#finalize the policy
 attr.attribute_bake()
+
+#write out the policy to a credential file
 attr.attribute_write_cert("mary_what2eat__ralphs_fruitprice_qP_attr.der")
+
+# load the rule back into context via credential file
 ctxt.load_attribute_file("mary_what2eat__ralphs_fruitprice_qP_attr.der")
 print attr.string() 
@@ -59,16 +80,24 @@
 
 ################################################
+# Credential 2,
 # [keyid:bob].oset:what2eat
 #      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
 head = ABAC.Oset(bob,"what2eat")
+
+# initialze a float range constraint
 cond=ABAC.Constraint("float")
+
+# add the min and max value to the range
 cond.constraint_add_float_min(1.00)
 cond.constraint_add_float_max(5.00)
-print cond.typed_string()
 param=ABAC.DataTerm("float", "P", cond)
 tail = ABAC.Oset(ralphs,"fruitprice")
 tail.oset_add_data_term(param)
+
+#create attribute policy
 attr=ABAC.Attribute(head, 1800)
 attr.attribute_add_tail(tail)
+
+#finalize the policy
 attr.attribute_bake()
 attr.attribute_write_cert("bob_what2eat__ralphs_fruitprice_qP_attr.der")
@@ -79,4 +108,5 @@
 
 #################################################
+# Credential 3
 # [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
 param=ABAC.DataTerm("float", "1.50")
@@ -95,4 +125,5 @@
 
 #################################################
+# Credential 4
 # [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'kiwi']
 param=ABAC.DataTerm("float", "1.50")
@@ -111,4 +142,5 @@
 
 #################################################
+# Credential 5
 # [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black berry']
 param=ABAC.DataTerm("float", "2.50")
@@ -127,4 +159,5 @@
 
 #################################################
+# Credential 6
 # [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
 param=ABAC.DataTerm("float", "0.50")
@@ -142,5 +175,2 @@
 print "\n"
 
-##
-ctxt.dump_yap_db()
-##
Index: examples/python_tests/fruits_rt2/fruit.save
===================================================================
--- examples/python_tests/fruits_rt2/fruit.save	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/fruits_rt2/fruit.save	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,4 +1,17 @@
 % Restoring file /usr/local/lib/Yap/startup.yss
    
+...final principal set...
+(pBob,keyid,y) 
+(pMary,keyid,y) 
+(pRalphs,keyid,y) 
+
+...final policy attribute set...
+pRalphs.fruitprice(1.50) <- 'apple'
+pRalphs.fruitprice(2.50) <- 'black berry'
+pRalphs.fruitprice(1.50) <- 'kiwi'
+pRalphs.fruitprice(0.50) <- 'navel orange'
+pBob.what2eat <- pRalphs.fruitprice(P:[1.000000 .. 5.000000])
+pMary.what2eat <- pRalphs.fruitprice(P:[.. 2.000000])
+
 ===good============ mary.what2eat <- navel orange
 YAP query succeed
@@ -20,19 +33,2 @@
 ===bad============ ralphs.fruitprice(1.50) <- green apple
 YAP query failed
-
-...final principal set...
-(pBob,keyid,y) 
-(pMary,keyid,y) 
-(pRalphs,keyid,y) 
-
-
-
-...final policy attribute set...
-pRalphs.fruitprice(1.50) <- 'apple'
-pRalphs.fruitprice(2.50) <- 'black berry'
-pRalphs.fruitprice(1.50) <- 'kiwi'
-pRalphs.fruitprice(0.50) <- 'navel orange'
-pBob.what2eat <- pRalphs.fruitprice(P:[1.000000 .. 5.000000])
-pMary.what2eat <- pRalphs.fruitprice(P:[.. 2.000000])
-
-
Index: examples/python_tests/fruits_rt2/query.py
===================================================================
--- examples/python_tests/fruits_rt2/query.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/fruits_rt2/query.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,5 +2,5 @@
 
 """
-  to test with python
+Run the queries described in README
 
 cmd1:env keystore=`pwd` ./query.py 
@@ -14,10 +14,14 @@
 ctxt = ABAC.Context()
 
-# print "ABAC version %s" % ctxt.version()
+# Keystore is the directory containing the principal credentials.
+# Load existing principals and/or policy credentials
+if (os.environ.has_key("keystore")) :
+    keystore=os.environ["keystore"]
+    ctxt.load_directory(keystore)
+else:
+    print("keystore is not set...")
+    exit(1)
 
-keystore=os.environ["keystore"]
-
-ctxt.load_directory(keystore)
-
+# retrieve principals' keyid value from local credential files
 ralphsID=ABAC.ID("Ralphs_ID.pem");
 ralphsID.id_load_privkey_file("Ralphs_private.pem");
@@ -33,4 +37,17 @@
 
 ##########################################################################
+# dump the loaded principals/policies
+#
+out = ctxt.context_principals()
+print "\n...final principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+out = ctxt.context_credentials()
+print "\n...final policy attribute set..."
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# Would Mary eat navel orange ?
 # oset = [keyid:mary].oset:what2eat 
 # p [string:'navel orange'] 
@@ -45,4 +62,5 @@
 
 ##########################################################################
+# Would Mary eat kiwi ?
 # oset = [keyid:mary].oset:what2eat 
 # p [string:'kiwi'] 
@@ -57,4 +75,5 @@
 
 ##########################################################################
+# Would Bob eat navel orange ?
 # oset = [keyid:bob].oset:what2eat 
 # p [string:'navel orange'] 
@@ -69,4 +88,5 @@
 
 ##########################################################################
+# Is Apple 1.50 at Ralphs ?
 # oset = [keyid:$ralphs].oset:fruitprice([float:1.50]) 
 # p = [string:'apple'] 
@@ -83,4 +103,5 @@
 
 ##########################################################################
+# Is green apple 1.50 at Ralphs ?
 # oset = [keyid:$ralphs].oset:fruitprice([float:1.50]) 
 # p = [string:'green apple'] 
@@ -101,18 +122,2 @@
 #ctxt.dump_yap_db()
 
-##########################################################################
-# dump the loaded principals/policies
-#
-out = ctxt.context_principals()
-print "\n...final principal set..."
-for x in out[1]:
-    print "%s " % x.string()
-print "\n"
-out = ctxt.context_credentials()
-print "\n...final policy attribute set..."
-for c in out[1]:
-    print "%s <- %s" % (c.head_string(), c.tail_string())
-print "\n"
-
-
-
Index: examples/python_tests/fruits_rt2/run_test
===================================================================
--- examples/python_tests/fruits_rt2/run_test	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/fruits_rt2/run_test	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,6 +1,3 @@
 #!/bin/sh 
-
-ABAC_PROVER_PATH="/home/mei/Deter/abac/libabac"
-export ABAC_PROVER_PATH
 
 echo '---setup principals'
Index: examples/python_tests/fruits_rt2/setup.py
===================================================================
--- examples/python_tests/fruits_rt2/setup.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/fruits_rt2/setup.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,4 +2,6 @@
 
 """
+See README for the semantics.  This creates principals
+used by the example.
 """
 import os
