[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r6371 - trunk/gnue-appserver/src/gld
From: |
johannes |
Subject: |
r6371 - trunk/gnue-appserver/src/gld |
Date: |
Wed, 22 Sep 2004 04:43:22 -0500 (CDT) |
Author: johannes
Date: 2004-09-22 04:43:21 -0500 (Wed, 22 Sep 2004)
New Revision: 6371
Modified:
trunk/gnue-appserver/src/gld/readgld.py
Log:
Calculated fields can now be defined either using <property name="foobar"> or
<procedure name="getfoobar">
Modified: trunk/gnue-appserver/src/gld/readgld.py
===================================================================
--- trunk/gnue-appserver/src/gld/readgld.py 2004-09-22 08:34:14 UTC (rev
6370)
+++ trunk/gnue-appserver/src/gld/readgld.py 2004-09-22 09:43:21 UTC (rev
6371)
@@ -147,64 +147,38 @@
self.connections.loginToConnection (connection)
- attributes = {'name' : "dts_gnueModule",
- 'database': self.OPTIONS ['connection'],
- 'table' : 'gnue_module'}
- fieldList = ['gnue_id', 'gnue_name']
+ self._dtsModules = self.__getDatasource ('gnue_module', ['gnue_id',
+ 'gnue_name'])
- self._dtsModules = GDataSource.DataSourceWrapper (
- connections = self.connections,
- attributes = attributes,
- fields = fieldList,
- unicodeMode = True)
+ self._dtsClasses = self.__getDatasource ('gnue_class', ['gnue_id',
+ 'gnue_name', 'gnue_module'])
- attributes = {'name' : "dts_gnueClass",
- 'database': self.OPTIONS ['connection'],
- 'table' : 'gnue_class'}
- fieldList = ['gnue_id', 'gnue_name', 'gnue_module']
+ self._dtsProperty = self.__getDatasource ('gnue_property', ['gnue_id',
+ 'gnue_name', 'gnue_module', 'gnue_class'])
- self._dtsClasses = GDataSource.DataSourceWrapper (
- connections = self.connections,
- attributes = attributes,
- fields = fieldList,
- unicodeMode = True)
+ self._dtsProcedure = self.__getDatasource ('gnue_procedure', ['gnue_id',
+ 'gnue_name', 'gnue_module', 'gnue_class', 'gnue_type'])
- attributes = {'name' : "dts_gnueProperty",
- 'database': self.OPTIONS ['connection'],
- 'table' : 'gnue_property'}
- fieldList = ['gnue_id', 'gnue_name', 'gnue_module', 'gnue_class']
+ self._dtsLabel = self.__getDatasource ('gnue_label', ['gnue_id',
+ 'gnue_property', 'gnue_language', 'gnue_position', 'gnue_page',
+ 'gnue_label', 'gnue_procedure', 'gnue_search', 'gnue_info'])
- self._dtsProperty = GDataSource.DataSourceWrapper (
- connections = self.connections,
- attributes = attributes,
- fields = fieldList,
- unicodeMode = True)
+ self._dtsParameter = self.__getDatasource ('gnue_parameter', ['gnue_id'])
- attributes = {'name' : "dts_gnueProcedure",
- 'database': self.OPTIONS ['connection'],
- 'table' : 'gnue_procedure'}
- fieldList = ['gnue_id', 'gnue_name', 'gnue_module', 'gnue_class']
- self._dtsProcedure = GDataSource.DataSourceWrapper (
- connections = self.connections,
- attributes = attributes,
- fields = fieldList,
- unicodeMode = True)
+ # ---------------------------------------------------------------------------
+ # Create a new datasource for a given table
+ # ---------------------------------------------------------------------------
+ def __getDatasource (self, table, fieldList):
+ return GDataSource.DataSourceWrapper ( \
+ connections = self.connections,
+ attributes = {'name' : "dts_%s" % table,
+ 'database': self.OPTIONS ['connection'],
+ 'table' : table},
+ fields = fieldList,
+ unicodeMode = True)
- attributes = {'name' : "dts_gnueLabel",
- 'database': self.OPTIONS ['connection'],
- 'table' : 'gnue_label'}
- fieldList = ['gnue_id', 'gnue_property', 'gnue_language', 'gnue_position',
- 'gnue_page', 'gnue_label', 'gnue_procedure', 'gnue_search',
- 'gnue_info']
-
- self._dtsLabel = GDataSource.DataSourceWrapper (
- connections = self.connections,
- attributes = attributes,
- fields = fieldList,
- unicodeMode = True)
-
# ---------------------------------------------------------------------------
# Main program
# ---------------------------------------------------------------------------
@@ -324,8 +298,14 @@
pDef ['class'] = defs ['gnue_id']
if sObject._type == 'GLProperty':
- pDef ['gnue_id'] = self.__findProperty (pDef, sObject._parent)
- pDef ['relation'] = 'gnue_property'
+ try:
+ pDef ['gnue_id'] = self.__findProperty (pDef, sObject._parent)
+ pDef ['relation'] = 'gnue_property'
+
+ except PropertyNotFoundError:
+ pDef ['gnue_id'] = self.__findCalculated (pDef, sObject._parent)
+ pDef ['relation'] = 'gnue_procedure'
+
else:
pDef ['gnue_id'] = self.__findProcedure (pDef, sObject._parent)
pDef ['relation'] = 'gnue_procedure'
@@ -387,6 +367,7 @@
rs = self._dtsProperty.createResultSet (mc)
if rs.firstRecord () is None:
raise PropertyNotFoundError, (pDef ['name'], parent.fullName)
+
return rs.current.getField ('gnue_id')
@@ -405,6 +386,40 @@
# ---------------------------------------------------------------------------
+ # Find a calculated property by name-, module- and class-id
+ # ---------------------------------------------------------------------------
+
+ def __findCalculated (self, pDef, parent):
+ mc = GConditions.buildConditionFromDict (\
+ {'gnue_module': pDef ['module'],
+ 'gnue_class' : pDef ['class'],
+ 'gnue_name' : "get%s" % pDef ['name']})
+
+ rs = self._dtsProcedure.createResultSet (mc)
+ if rs.firstRecord () is None:
+ raise PropertyNotFoundError, (pDef ['name'], parent.fullName)
+
+ if rs.current.getField ('gnue_type') is None:
+ raise PropertyNotFoundError, (pDef ['name'], parent.fullName)
+
+ rec = rs.current
+
+ while rec is not None:
+ mc = GConditions.buildConditionFromDict ( \
+ {'gnue_procedure': rec.getField ('gnue_id')})
+ prs = self._dtsParameter.createResultSet (mc)
+ if prs.firstRecord () is None:
+ pDef ['name'] = "get%s" % pDef ['name']
+ break
+
+ rec = rs.nextRecord ()
+
+ if rec is None:
+ raise PropertyNotFoundError, (pDef ['name'], parent.fullName)
+
+ return rec.getField ('gnue_id')
+
+ # ---------------------------------------------------------------------------
# Get a dictionary with all keys listed in tags and values from sObject
# ---------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r6371 - trunk/gnue-appserver/src/gld,
johannes <=