commit-gnue
[Top][All Lists]
Advanced

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

r5103 - trunk/gnue-appserver/src


From: reinhard
Subject: r5103 - trunk/gnue-appserver/src
Date: Thu, 12 Feb 2004 09:34:34 -0600 (CST)

Author: reinhard
Date: 2004-02-12 09:34:33 -0600 (Thu, 12 Feb 2004)
New Revision: 5103

Modified:
   trunk/gnue-appserver/src/geasList.py
   trunk/gnue-appserver/src/geasSession.py
Log:
A little code cleanup and restructuring.


Modified: trunk/gnue-appserver/src/geasList.py
===================================================================
--- trunk/gnue-appserver/src/geasList.py        2004-02-12 15:04:54 UTC (rev 
5102)
+++ trunk/gnue-appserver/src/geasList.py        2004-02-12 15:34:33 UTC (rev 
5103)
@@ -34,43 +34,13 @@
   # Initalize
   # ---------------------------------------------------------------------------
 
-  def __init__ (self, session, connection, classdef, propertylist, sortorder):
+  def __init__ (self, session, classdef, recordset, propertylist):
     self.__session = session
-    self.__connection = connection
     self.__classdef = classdef
+    self.__recordset = recordset
     self.__prefetch = propertylist      # property names to be prefetched
-    self.__sort = sortorder             # property names of the sort key
 
-    self.__prefColumns = []             # (db) column names to be prefetched
-    self.__sortColumns = []             # (db) column names of the sort key
-
-    # test if all properties in prefetch list are valid and find column names
-    for propertyname in self.__prefetch:
-      propertydef = self.__classdef.properties [propertyname]
-      self.__prefColumns.append (propertydef.column)
-
-    # test if all properties in sort list are valid and find column names
-    for propertyname in self.__sort:
-      propertydef = self.__classdef.properties [propertyname]
-      self.__sortColumns.append (propertydef.column)
-
   # ---------------------------------------------------------------------------
-  # Populate the list with data from the database backend
-  # ---------------------------------------------------------------------------
-  # conditions = a list consisting of condition elements written down in
-  # prefix notation i.e. (a=12) AND (c=121) -> AND = a 12 = c 121
-  # every element of the list is a tuple containing the following parts:
-  # type (eq,and,const...)  value  i.e. ('eq','') or ('const',12)
-  # ---------------------------------------------------------------------------
-
-  def populate (self, conditions):
-    # TODO: translate property names to column names in conditions
-    self.__recordset = self.__connection.query (self.__classdef.table,
-                                                self.__prefColumns, 
-                                                conditions,
-                                                self.__sortColumns)
-
-  # ---------------------------------------------------------------------------
   # Get the first instance in the list
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-appserver/src/geasSession.py
===================================================================
--- trunk/gnue-appserver/src/geasSession.py     2004-02-12 15:04:54 UTC (rev 
5102)
+++ trunk/gnue-appserver/src/geasSession.py     2004-02-12 15:34:33 UTC (rev 
5103)
@@ -57,7 +57,7 @@
   # Get a class definition from a class name and check access
   # ---------------------------------------------------------------------------
 
-  def __get_classdef (self, classname):
+  def __getClassdef (self, classname):
 
     # check if user has access rights for this class
     if not self.__authAdapter.hasAccess (self, self.__user, classname):
@@ -69,7 +69,7 @@
   # Get a list of field names from a list of property names
   # ---------------------------------------------------------------------------
 
-  def __get_fieldlist (self, classdef, propertylist):
+  def __getFieldlist (self, classdef, propertylist):
 
     return ([classdef.properties[p].column for p in propertylist])
 
@@ -121,12 +121,18 @@
 
   def request (self, classname, conditions, sortorder, propertylist):
 
-    classdef = self.__get_classdef (classname)
-    list = geasList.geasList (self, self.__connection, classdef, 
-                              ['gnue_id'] + propertylist,
-                              sortorder)
+    classdef = self.__getClassdef (classname)
 
-    list.populate (conditions)
+    # TODO: translate property names to column names in conditions
+    sortlist = self.__getFieldlist (classdef, sortorder)
+    fieldlist = self.__getFieldlist (classdef, ['gnue_id'] + propertylist)
+
+    recordset = self.__connection.query (classdef.table, fieldlist, conditions,
+                                         sortlist)
+
+    list = geasList.geasList (self, classdef, recordset,
+                              ['gnue_id'] + propertylist)
+
     self.__listcount += 1
     self.__lists [self.__listcount] = list
     list_id = self.__listcount
@@ -168,7 +174,7 @@
   def __findInstance (self, classdef, object_id, propertylist):
 
     table = classdef.table
-    fieldlist = self.__get_fieldlist (classdef, propertylist)
+    fieldlist = self.__getFieldlist (classdef, propertylist)
     record = self.__connection.findRecord (table, object_id, fieldlist)
     return geasInstance.geasInstance (self, record, classdef)
 
@@ -188,7 +194,7 @@
 
   def load (self, classname, obj_id_list, propertylist):
 
-    classdef = self.__get_classdef (classname)
+    classdef = self.__getClassdef (classname)
 
     result = []
     for object_id in obj_id_list:
@@ -206,7 +212,7 @@
 
   def store (self, classname, obj_id_list, propertylist, data):
 
-    classdef = self.__get_classdef (classname)
+    classdef = self.__getClassdef (classname)
 
     result = []
     i = 0
@@ -228,7 +234,7 @@
 
   def delete (self, classname, obj_id_list):
 
-    classdef = self.__get_classdef (classname)
+    classdef = self.__getClassdef (classname)
 
     for object_id in obj_id_list:
       self.__connection.deleteRecord (classdef.table, object_id)
@@ -239,7 +245,7 @@
 
   def call (self, classname, obj_id_list, procedurename, parameters):
 
-    classdef = self.__get_classdef (classname)
+    classdef = self.__getClassdef (classname)
 
     result = []
     for object_id in obj_id_list:





reply via email to

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