[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/examples/python querytest.py schema.py
From: |
Neil Tiffin |
Subject: |
gnue/geas/examples/python querytest.py schema.py |
Date: |
Sun, 09 Sep 2001 18:34:27 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/09/09 18:34:27
Modified files:
geas/examples/python: querytest.py schema.py
Log message:
Add proper language query to abtain help, tool tip and field label data
from geas.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/querytest.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/schema.py.diff?cvsroot=OldCVS&tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: gnue/geas/examples/python/querytest.py
diff -u gnue/geas/examples/python/querytest.py:1.4
gnue/geas/examples/python/querytest.py:1.5
--- gnue/geas/examples/python/querytest.py:1.4 Thu Aug 23 16:02:47 2001
+++ gnue/geas/examples/python/querytest.py Sun Sep 9 18:34:27 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: querytest.py,v 1.4 2001/08/23 23:02:47 ntiffin Exp $
+# $Id: querytest.py,v 1.5 2001/09/10 01:34:27 ntiffin Exp $
import sys
import md5
@@ -62,8 +62,8 @@
lst = con.executeQuery(q1)
print "execution done"
if lst != None:
- for o in lst.objects:
- print o.getField("id") , " " , o.getField("name")
+ for o in lst.objects:
+ print o.getField("id") , " " , o.getField("name")
q1.release()
except ServerError,ex:
Index: gnue/geas/examples/python/schema.py
diff -u gnue/geas/examples/python/schema.py:1.9
gnue/geas/examples/python/schema.py:1.10
--- gnue/geas/examples/python/schema.py:1.9 Sun Sep 9 11:46:02 2001
+++ gnue/geas/examples/python/schema.py Sun Sep 9 18:34:27 2001
@@ -7,27 +7,69 @@
# a test file: relies on GEAS being run from gnue/geas/src
# and this from gnue/geas/examples/python
#
-# $Id: schema.py,v 1.9 2001/09/09 18:46:02 ntiffin Exp $
+# $Id: schema.py,v 1.10 2001/09/10 01:34:27 ntiffin Exp $
import re
import sys
import md5
from string import *
-def show_help_info( name, field):
- # TODO does not handle language correctly
+
+def get_help_object2( full_class_name, field_name, language = "en",
dialect="us"):
+ # does not handle language correctly but is very fast
+ # use get_help_object1
classname = "language::help"
fieldname = "name"
- fieldcontents = re.sub("::", "__", name+"."+field)
- fieldcontents = re.sub("root__", "", fieldcontents)
- # print "Looking for: " + fieldcontents
- obj = con.loadSingleObject( classname, fieldname, fieldcontents)
+ fieldcontents = re.sub(r'::', '__', full_class_name+"."+field_name)
+ fieldcontents = re.sub(r'^root__', '', fieldcontents)
+ # print "Looking for: " + fieldcontents
+ helpObject = con.loadSingleObject( classname, fieldname, fieldcontents)
+ return helpObject
+
+
+ # this is the correct function to handle language but
+ # this function is at least one order of magnitude slower
+ # than get_help_object2
+def get_help_object1( full_class_name, field_name, language = "en",
dialect="us"):
+ fieldcontents = re.sub(r'::', '__', full_class_name+"."+field_name)
+ fieldcontents = re.sub(r'^root__', '', fieldcontents)
+ try:
+ query = con.newQuery()
+ query.classname = "language::help"
+ query.orderby = "name"
+ query.reverse = CORBA.FALSE
+ query.logic = GEAS.Query.AND
+ f1 = GEAS.Query.Field( field="name",test=GEAS.Query.equals,
+ invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value=fieldcontents)
+ query.addField(f1)
+ f2 = GEAS.Query.Field( field="code",test=GEAS.Query.equals,
+ invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value=language)
+ query.addField(f2)
+ f3 = GEAS.Query.Field( field="dialect",test=GEAS.Query.equals,
+ invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value=dialect)
+ query.addField(f3)
+ obj_list = con.executeQuery(query)
+ query.release()
+
+ except ServerError,ex:
+ # TODO
+ print "ServerError: " + ex.detail
+ except UnknownClass,ex:
+ # TODO
+ print "Unknown Class error: " + ex.detail
+
+ return obj_list.objects[0]
+
+
+def show_help_info( name, field):
+ obj = get_help_object1( name, field )
if obj:
- print " Help Text : " + obj.getField("help_text")
- print " Tool Tip : " + obj.getField("tool_tip")
- print " Label : " + obj.getField("label")
+ print " Help Text : " + obj.getField("help_text")
+ print " Tool Tip : " + obj.getField("tool_tip")
+ print " Label : " + obj.getField("label")
return
+
def get_numeric_input(a_string, min_value, max_value):
idx = max_value + 1
while idx < min_value or idx > max_value:
@@ -44,6 +86,7 @@
idx = atoi( cmd )
print ""
return idx
+
def show_classnames( classes ):
i = 1
@@ -61,6 +104,7 @@
return data
+
def show_fields( class_definition ):
if len(class_definition.fields) == 0: print " (None)"
else: print ""
@@ -155,6 +199,7 @@
return
+
def show_classname( class_definition ):
print ""
print "Class Name: " + class_definition.name + ", Parents: ",
@@ -175,7 +220,6 @@
print "Failed to load CORBA module."
print "Please see http://sourceforge.net/projects/orbit-python for the
required python CORBA bindings"
sys.exit(0)
-
try:
orb = CORBA.ORB_init( () , "orbit-local-orb" )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/examples/python querytest.py schema.py,
Neil Tiffin <=