commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue geas/examples/businessobjects/methods/test...


From: Neil Tiffin
Subject: gnue geas/examples/businessobjects/methods/test...
Date: Tue, 25 Sep 2001 09:56:43 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Neil Tiffin <address@hidden>    01/09/25 09:56:42

Modified files:
        geas/examples/businessobjects/methods: test.py 
        geas/examples/python: neil_methods_test.py 
        geas/lib/classdefs: classdata.c 
        geas/src/methods: methods_python.c 
        gnue-config/base/currency/methods: currency.py 
        gnue-config/test: gcd_pass_test.gcd gcd_pass_test.py 

Log message:
        Change sequence of args for calling python methods from (obj, args...., 
server) to (obj, server, args...). Remove two asserts that hit when calling 
connection.countAllInstances() from client.  Change .py files for new calling 
sequence.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/businessobjects/methods/test.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/neil_methods_test.py.diff?cvsroot=OldCVS&tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.70&tr2=1.71&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/methods/methods_python.c.diff?cvsroot=OldCVS&tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-config/base/currency/methods/currency.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-config/test/gcd_pass_test.gcd.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-config/test/gcd_pass_test.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue/geas/examples/businessobjects/methods/test.py
diff -u gnue/geas/examples/businessobjects/methods/test.py:1.4 
gnue/geas/examples/businessobjects/methods/test.py:1.5
--- gnue/geas/examples/businessobjects/methods/test.py:1.4      Mon Feb 19 
15:08:14 2001
+++ gnue/geas/examples/businessobjects/methods/test.py  Tue Sep 25 09:56:42 2001
@@ -1,7 +1,7 @@
 
 import string
 
-def test_callme(obj,a,b,server):
+def test_callme(obj,server, a, b):
     print "callme called"
     print "this.name = " + obj.getField("name")
     return obj.getField("name")
Index: gnue/geas/examples/python/neil_methods_test.py
diff -u gnue/geas/examples/python/neil_methods_test.py:1.8 
gnue/geas/examples/python/neil_methods_test.py:1.9
--- gnue/geas/examples/python/neil_methods_test.py:1.8  Mon Sep 24 13:10:00 2001
+++ gnue/geas/examples/python/neil_methods_test.py      Tue Sep 25 09:56:42 2001
@@ -3,7 +3,7 @@
 # a test file: relies on GEAS being run from gnue/geas/src
 # and this from gnue/geas/examples/python
 
-# $Id: neil_methods_test.py,v 1.8 2001/09/24 17:10:00 ntiffin Exp $
+# $Id: neil_methods_test.py,v 1.9 2001/09/25 13:56:42 ntiffin Exp $
 
 import sys
 import md5
@@ -11,9 +11,12 @@
 import whrandom
 from string import * 
 
-print "neil_methods_test.py"
-print time.asctime(time.gmtime()), "UTC"
 print
+print "Program name: neil_methods_test.py"
+print "        Date: %s UTC" % time.asctime(time.gmtime())
+print "Sys Platform: %s" % sys.platform
+print "Sys  Version: %s" % sys.version
+print
 
 try:
     import CORBA
@@ -91,6 +94,11 @@
    if obj_list == None:
       return []   
    return obj_list
+   
+def count_instances( classname ):
+   print "Number Instances in class %s is %i." % (classname, 
con.countAllInstances(classname))
+   return
+
 print
 print "This query test requires the zip code database be loaded into GEAS."
 print "Email address@hidden if you do not have a copy of it"
@@ -101,6 +109,7 @@
 print "loop count = %i" % num_loops
 print
 
+count_instances( "mod1::class1" )
 # first test is create objects
 x = 0
 time_start = time.time()
@@ -116,6 +125,7 @@
 create_and_set_time = (time_end - time_start) / x
 print "time to create object and set one field = ", "%.3f" % 
(create_and_set_time*1000), " milliseconds."
 
+count_instances( "mod1::class1" )
 x = 0
 a = "a"
 b = "b"
@@ -140,9 +150,22 @@
 create_and_set_method_time = (time_end - time_start) / x
 print "time to create object, set one field, and call method = ", "%.3f" % 
(create_and_set_method_time*1000), " milliseconds."
 print "time to call a method only = ", "%.3f" % ((create_and_set_method_time - 
create_and_set_time)*1000), " milliseconds."
+count_instances( "mod1::class1" )
+print
+
+# SELECT count(*) FROM location__post_code;
+print "Check how long it takes to count instances of an object."
+classname = "location::post_code"
+start_time = time.time()
+instances = con.countAllInstances(classname)
+end_time = time.time()
+if (instances != 29458):
+    print "**** Error in count for class %s, expecting 29458, received %i." % 
(classname, instances)
+else:
+    print "Correctly found %i instances in %s." % (instances, classname)
+print "Time to count instances was %.3f seconds." % (end_time - start_time)
 print
 
-print "Testing startswith query"
 # this test should be the same as executing the following queries
 # SELECT count(*) FROM location__post_code WHERE city LIKE 'M%' AND zip_code 
LIKE '68%';
 # SELECT count(*) FROM location__post_code WHERE city LIKE 'M%' AND zip_code 
LIKE '4%';
@@ -182,12 +205,12 @@
 print
 
 print "Testing lessthan and greaterthan query"
-# SELECT count(*) from location__post_code WHERE zip_code > 20000 and zip_code 
< 20199;
+# SELECT count(*) from location__post_code WHERE zip_code > 20000 and zip_code 
< 31000;
 x = 0
 num_records = 0
-min_test = [20000]
-max_test = [20199]
-cor_result = [22]
+min_test = [20000, 20000]
+max_test = [20199, 31000]
+cor_result = [22, 3342]
 total_time_start = time.time()
 while (x < len(min_test) ):
     # zip1 = whrandom.randint(10000, 99999)
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.70 
gnue/geas/lib/classdefs/classdata.c:1.71
--- gnue/geas/lib/classdefs/classdata.c:1.70    Sun Sep 23 12:56:10 2001
+++ gnue/geas/lib/classdefs/classdata.c Tue Sep 25 09:56:42 2001
@@ -22,7 +22,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
 
-   $Id: classdata.c,v 1.70 2001/09/23 16:56:10 ntiffin Exp $
+   $Id: classdata.c,v 1.71 2001/09/25 13:56:42 ntiffin Exp $
    
 */
 
@@ -660,7 +660,8 @@
   struct _odl_base *item;
 
 #ifdef DEBUG
-  assert (name != NULL);
+  /* causes fault when connection.countAllInstances(classname) is called */
+  /* assert (name != NULL); */
   assert (tree != NULL);
 #endif
   item = (struct _odl_base *) odl_find_item (tree, name, id);
@@ -763,8 +764,8 @@
   GList *l;
   odl_base *retval = NULL;
   char *tmp;
-
-  g_assert (name != NULL);
+  /* causes assert when con.countAllInstances(classname) is called from client 
*/
+  /* g_assert (name != NULL); */
   g_assert (tree != NULL);
 
   /* cos it's a const input, make a temp. duplicate */
Index: gnue/geas/src/methods/methods_python.c
diff -u gnue/geas/src/methods/methods_python.c:1.15 
gnue/geas/src/methods/methods_python.c:1.16
--- gnue/geas/src/methods/methods_python.c:1.15 Mon Sep 24 12:31:33 2001
+++ gnue/geas/src/methods/methods_python.c      Tue Sep 25 09:56:42 2001
@@ -19,7 +19,7 @@
   along with GEAS; if not, write to the Free Software Foundation, Inc.,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-  $Id: methods_python.c,v 1.15 2001/09/24 16:31:33 ntiffin Exp $
+  $Id: methods_python.c,v 1.16 2001/09/25 13:56:42 ntiffin Exp $
 */
 
 /*
@@ -372,6 +372,7 @@
   if (ev->_major != CORBA_NO_EXCEPTION)
     {
       /* didn't work */
+      errormsg("Could not make object reference for class %s.", 
obj->classname);
       return (NULL);
     }
 
@@ -381,6 +382,7 @@
     {
       /* didn't work */
       CORBA_Object_release (obj2, ev);
+      errormsg("Could not make connection reference for user %s.", 
obj->username);
       return (NULL);
     }
 
@@ -419,13 +421,13 @@
 
       /* PyObject_Print(pyobj, stdout, 0); */
       l = PyList_New (0);
-      PyList_Append (l, pyobj);
+      PyList_Append (l, pyobj);     /* the object being operated on */
+      PyList_Append (l, server);    /* the connection */
 
       for (i = 0; i < args->_length; i++)
         {
           PyList_Append (l, PyString_FromString (args->_buffer[i]));
         }
-      PyList_Append (l, server);
       tuple = PyList_AsTuple (l);
 
       result = PyObject_CallObject (function, tuple);
Index: gnue/gnue-config/base/currency/methods/currency.py
diff -u gnue/gnue-config/base/currency/methods/currency.py:1.2 
gnue/gnue-config/base/currency/methods/currency.py:1.3
--- gnue/gnue-config/base/currency/methods/currency.py:1.2      Sun Sep 23 
20:20:36 2001
+++ gnue/gnue-config/base/currency/methods/currency.py  Tue Sep 25 09:56:42 2001
@@ -21,10 +21,10 @@
 #
 # This file originally written by Neil Tiffin (address@hidden).
 #
-# $Revision: 1.2 $ $Date: 2001/09/24 00:20:36 $ $Author: ntiffin $
+# $Revision: 1.3 $ $Date: 2001/09/25 13:56:42 $ $Author: ntiffin $
 #
 
-def currency__conversion_convert_to( from_obj, to_currency, from_value, 
conv_date, server ):
+def currency__conversion_convert_to( obj, con, to_currency, from_value, 
conv_date ):
     cv_rules = from_obj.getList("rule")
     # find the right conversion
     for o in cv_rules.objects:
Index: gnue/gnue-config/test/gcd_pass_test.gcd
diff -u gnue/gnue-config/test/gcd_pass_test.gcd:1.3 
gnue/gnue-config/test/gcd_pass_test.gcd:1.4
--- gnue/gnue-config/test/gcd_pass_test.gcd:1.3 Sun Sep 23 10:18:12 2001
+++ gnue/gnue-config/test/gcd_pass_test.gcd     Tue Sep 25 09:56:42 2001
@@ -23,7 +23,7 @@
 #
 # This file originally written by Neil Tiffin (address@hidden).
 #
-# $Revision: 1.3 $ $Date: 2001/09/23 14:18:12 $ $Author: ntiffin $
+# $Revision: 1.4 $ $Date: 2001/09/25 13:56:42 $ $Author: ntiffin $
 #
 
 module mod1
@@ -60,11 +60,19 @@
       
       list list_fld : mod1::c(code) = this.char_8_fld;
 
-      # concatenate a and b together
+      # concatenate a and b together to check
+      # arg passing
       text       cat_a_b(char a, char b);
-
+      
+      # check obj reference by returning class name
+      # check no arguments
+      text       get_class_name();
+      
+      # check con reference by returning user id
+      text       get_user();
     };
 
+  # check single character class names
   class c
     {
       char       code<8>;
Index: gnue/gnue-config/test/gcd_pass_test.py
diff -u gnue/gnue-config/test/gcd_pass_test.py:1.2 
gnue/gnue-config/test/gcd_pass_test.py:1.3
--- gnue/gnue-config/test/gcd_pass_test.py:1.2  Sun Sep 23 17:06:33 2001
+++ gnue/gnue-config/test/gcd_pass_test.py      Tue Sep 25 09:56:42 2001
@@ -21,11 +21,24 @@
 #
 # This file originally written by Neil Tiffin (address@hidden).
 #
-# $Revision: 1.2 $ $Date: 2001/09/23 21:06:33 $ $Author: ntiffin $
+# $Revision: 1.3 $ $Date: 2001/09/25 13:56:42 $ $Author: ntiffin $
 #
 
 import string
 
-def mod1__class1_cat_a_b(obj, a, b, server):
-
+# obj = an object reference to the object being operated on
+# con = a connectino object for global info
+# a = a string argument
+# b = a string argument
+def mod1__class1_cat_a_b(obj, con, a="A not defined. ", b="B Not Defined."):
   return a + b
+
+
+# this is for testing only, you would not do this in a class method
+def mod1__class1_get_class_name(obj, con):
+  return obj.classname
+
+
+# this is for testing only, you would not do this in a class method
+def mod1__class1_get_user(obj, con):
+  return con.currentUserID



reply via email to

[Prev in Thread] Current Thread [Next in Thread]