Index: examples/python_tests/acme_rockets_rt0/README
===================================================================
--- examples/python_tests/acme_rockets_rt0/README	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/acme_rockets_rt0/README	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,10 +1,10 @@
-#!/bin/sh
 #
 # The example makes use of 2 principals, Acme and Coyote.
 #
 # This example shows a very simple delegation of roles by Acme.  Acme's
-# buy_rockets role includes all of Acme's preferred customers.  The example
-# creates the principals and 2 credentials.  Credential 1 encodes the policy
-# that all of Acme's preferred customers can buy rockets from Acme and
+# buy_rockets role includes all of Acme's preferred customers.  The setup.py
+# creates the principals and the attr.py creates 2 policy credentials.  
+# Credential 1 encodes the policy that all of Acme's preferred customers 
+# can buy rockets from Acme and
 # Credential 2 defines the Coyote as an Acme preferred customer.
 
@@ -14,21 +14,10 @@
 # something other than a principal works (it doesn't).
 
-# acme_rockets_rt0_typed
+# acme_rockets_rt0
 
-creddy --generate --cn Acme
-creddy --generate --cn Coyote
+# Credential 1
+#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer 
 
-#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer 
-# Credential 1
-creddy --attribute \
-       --issuer Acme_ID.pem --key Acme_private.pem --role buy_rockets \
-       --subject-cert Acme_ID.pem --subject-role preferred_customer \
-       --out Acme_buy_rockets__Acme_preferred_customer_attr.der
+# Credential 2
+#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
 
-#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
-# Credential 2
-creddy --attribute \
-       --issuer Acme_ID.pem --key Acme_private.pem --role preferred_customer \
-       --subject-cert Coyote_ID.pem \
-       --out Acme_preferred_customer__Coyote_attr.der
-
Index: examples/python_tests/acme_rockets_rt0/attr.py
===================================================================
--- examples/python_tests/acme_rockets_rt0/attr.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/acme_rockets_rt0/attr.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,17 +2,16 @@
 
 """
-  Setup access policy attribute rules
+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 
-
 """
 import os
 import ABAC
 
-keystore=os.environ["keystore"]
-
 ctxt = ABAC.Context()
 print "ABAC version %s" % ctxt.version()
 
+# retrieve principals' keyid value from local credential files
 acmeID=ABAC.ID("Acme_ID.pem");
 acmeID.id_load_privkey_file("Acme_private.pem");
@@ -26,11 +25,20 @@
 
 ################################################
+# Credential 1, only preferred_customer of Acme can buy_rockets
 #[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer
 head = ABAC.Role(acme,"buy_rockets")
 tail = ABAC.Role(acme,"preferred_customer")
+
+# compose the attribute of a basic rt0 role rule
 attr=ABAC.Attribute(head, 1800)
 attr.attribute_add_tail(tail)
+
+# finalize the policy
 attr.attribute_bake()
+
+# create a policy file at the file system
 attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der")
+
+# load the policy into current context by with the newly created policy file
 ctxt.load_attribute_file("Acme_buy_rockets__Acme_preferred_customer_attr.der")
 print attr.string() 
@@ -39,4 +47,5 @@
 
 #################################################
+# Credential 2
 #[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
 head = ABAC.Role(acme,"preferred_customer")
@@ -51,4 +60,2 @@
 print "\n"
 
-ctxt.dump_yap_db()
-##
Index: examples/python_tests/acme_rockets_rt0/query.py
===================================================================
--- examples/python_tests/acme_rockets_rt0/query.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/acme_rockets_rt0/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
 acmeID=ABAC.ID("Acme_ID.pem");
 acmeID.id_load_privkey_file("Acme_private.pem");
@@ -29,4 +33,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())
+
+##########################################################################
+# is coyote a preferred_customer of Acme ?
 # role=[keyid:Acme].role:preferred_customer
 # p =[keyid:coyote]
@@ -39,4 +56,5 @@
 
 ##########################################################################
+# can coyote buy rockets from Acme ?
 # role=[keyid:Acme].role:buy_rockets
 # p =[keyid:coyote]
@@ -50,4 +68,5 @@
 
 ##########################################################################
+# is Acme a friend of coyote ?
 # role=[keyid:Coyote].role:friend
 # p=[keyid:Acme] 
@@ -59,18 +78,14 @@
     print "%s <- %s" % (c.head_string(), c.tail_string())
 
-
 ##########################################################################
-# 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..."
+# using complex role to ask a question.. expecting to fail 
+# role=[keyid:Acme].role:buy_rockets 
+# p=[keyid:Acme].role:preferred_customer
+role = ABAC.Role(acme,"buy_rockets")
+p = ABAC.Role(acme,"preferred_customer")
+print "\n===bad=============== Acme.buy_rockets <- Acme.preferred_customer"
+out = ctxt.query(role, p)
 for c in out[1]:
     print "%s <- %s" % (c.head_string(), c.tail_string())
-print "\n"
 
 
Index: examples/python_tests/acme_rockets_rt0/rocket.save
===================================================================
--- examples/python_tests/acme_rockets_rt0/rocket.save	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/acme_rockets_rt0/rocket.save	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,3 +1,11 @@
 % Restoring file /usr/local/lib/Yap/startup.yss
+
+...final principal set...
+(pAcme,keyid,y) 
+(pCoyote,keyid,y) 
+
+...final policy attribute set...
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.preferred_customer <- pCoyote
 
 ===good============ Acme.preferred_customer <- Coyote
@@ -13,13 +21,4 @@
 YAP query failed
 
-...final principal set...
-(pAcme,keyid,y) 
-(pCoyote,keyid,y) 
-
-
-
-...final policy attribute set...
-pAcme.buy_rockets <- pAcme.preferred_customer
-pAcme.preferred_customer <- pCoyote
-
-
+===bad=============== Acme.buy_rockets <- Acme.preferred_customer
+fail, a.o <- b.o and a.r <- a.r query is not implemented yet !!!
Index: examples/python_tests/acme_rockets_rt0/run_test
===================================================================
--- examples/python_tests/acme_rockets_rt0/run_test	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/acme_rockets_rt0/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/acme_rockets_rt0/setup.py
===================================================================
--- examples/python_tests/acme_rockets_rt0/setup.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/acme_rockets_rt0/setup.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,8 +2,6 @@
 
 """
-  Setup 4 principal ID credentials
-
-  Acme, Coyote, WarnerBros and Batman
-
+See README for the semantics. 
+sets up 2 (Acme, Coyote) principal ID credentials
 """
 import os
@@ -12,7 +10,7 @@
 ctxt = ABAC.Context()
 
-alpha=ABAC.ID("Acme", 0)
-alpha.id_write_cert("Acme_ID.pem")
-alpha.id_write_privkey("Acme_private.pem")
+acme=ABAC.ID("Acme", 0)
+acme.id_write_cert("Acme_ID.pem")
+acme.id_write_privkey("Acme_private.pem")
 
 coyote=ABAC.ID("Coyote", 0)
