[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7165 - trunk/gnue-common/src/datasources/drivers/appserver/appse
From: |
reinhard |
Subject: |
[gnue] r7165 - trunk/gnue-common/src/datasources/drivers/appserver/appserver |
Date: |
Fri, 11 Mar 2005 06:46:04 -0600 (CST) |
Author: reinhard
Date: 2005-03-11 06:46:01 -0600 (Fri, 11 Mar 2005)
New Revision: 7165
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
Log:
A little code cleanup.
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
2005-03-11 00:05:15 UTC (rev 7164)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
2005-03-11 12:46:01 UTC (rev 7165)
@@ -1,4 +1,4 @@
-# GNU Enterprise Datasource Library - Driver for GNUe-AppServer
+# GNU Enterprise Common Library - GNUe-AppServer DB Driver - Connection
#
# Copyright 2000-2005 Free Software Foundation
#
@@ -21,11 +21,6 @@
#
# $Id$
-#### ####
-#### IF YOU MODIFY ANY CONNECTION ####
-#### ATTRIBUTES, PLEASE UPDATE info.py ####
-#### ####
-
import sys
from gnue.common.apps import errors, GConfig, i18n
@@ -37,35 +32,98 @@
from gnue.common.datasources.drivers.appserver.Schema.Discovery.Introspection
import Introspection
+
# =============================================================================
-# Connection class
+# GNUe-AppServer Connection class
# =============================================================================
class Connection (Base.Connection):
"""
- Handles a connection to the GNUe-AppServer backend.
+ Connection class for GNUe-AppServer backends.
"""
+
defaultBehavior = Introspection
- supportedDataObjects = {
- 'object': DataObject.DataObject
- }
+ supportedDataObjects = {'object': DataObject.DataObject}
+
+
# ---------------------------------------------------------------------------
# Constructor
# ---------------------------------------------------------------------------
def __init__ (self, connections, name, parameters):
+
Base.Connection.__init__ (self, connections, name, parameters)
- self._filters = None
- self._server = None
+ self.__filters = None
+ self.__server = None
self._sm = None
-
+
# ---------------------------------------------------------------------------
+ # Create/return a connection to the appserver
+ # ---------------------------------------------------------------------------
+
+ def __getSessionManager (self):
+
+ if self.__server is None:
+ params = {'host' : self.parameters.get ('host'),
+ 'port' : self.parameters.get ('port'),
+ 'transport': self.parameters.get ('transport')}
+ rpcType = self.parameters.get ('rpctype')
+ self.__server = client.attach (rpcType, params)
+
+ if self.parameters.has_key ('timeout'):
+ self.__server.setTimeout (float (self.parameters ['timeout']))
+
+ if self._sm is None:
+ self._sm = self.__server.request ('Session')
+
+ return self._sm
+
+
+ # ---------------------------------------------------------------------------
+ # Update the given filter values
+ # ---------------------------------------------------------------------------
+
+ def __updateFilters (self, connectData):
+
+ for item in self.__filters:
+ (filterId, filterLabel) = item [0]
+
+ if connectData.has_key (filterId):
+ value = connectData [filterId]
+ (label, search, field) = item [1][0]
+
+ # if there are no filter values we've to skip replacement. Maybe the
+ # user just wants to add new filter values
+ if not len (item [3].keys ()):
+ continue
+
+ if item [2] is None:
+ masterkey = None
+ else:
+ masterkey = connectData [item [2]]
+
+ found = False
+ vDict = item [3][masterkey]
+ for record in vDict:
+ if record [field] == value:
+ connectData [filterId] = record ['gnue_id']
+ found = True
+ break
+
+ if not found:
+ raise Exceptions.LoginError, \
+ u_("'%(value)s' is not a valid filter-value for '%(filter)s'") \
+ % {'value': value,
+ 'filter': label}
+
+
+ # ---------------------------------------------------------------------------
# Define the needed information to log in
# ---------------------------------------------------------------------------
- def getLoginFields (self):
+ def _getLoginFields (self):
result = []
cfg = gConfigDict (section = 'appserver')
@@ -75,9 +133,9 @@
['_password', _('Password'), 1]])
self.__getSessionManager ()
- self._filters = self._sm.getFilters (i18n.getuserlocale ())
+ self.__filters = self._sm.getFilters (i18n.getuserlocale ())
- for item in self._filters:
+ for item in self.__filters:
(filterId, filterLabel) = item [0]
for (label, search, field) in item [1]:
result.append ([filterId, filterLabel + ':', False])
@@ -90,7 +148,7 @@
# Open a connection
# ---------------------------------------------------------------------------
- def connect (self, connectData):
+ def _connect (self, connectData):
self.__getSessionManager ()
self.__updateFilters (connectData)
@@ -108,7 +166,8 @@
# Commit active transaction
# ---------------------------------------------------------------------------
- def commit (self):
+ def _commit (self):
+
self._sm.commit (self._sess_id)
@@ -116,7 +175,7 @@
# Rollback active transaction
# ---------------------------------------------------------------------------
- def rollback (self):
+ def _rollback (self):
self._sm.rollback (self._sess_id)
@@ -124,66 +183,6 @@
# Close connection
# ---------------------------------------------------------------------------
- def close (self):
+ def _close (self):
if self._sm is not None:
self._sm.close (self._sess_id, False)
-
-
- # ---------------------------------------------------------------------------
- # Create/return a connection to the appserver
- # ---------------------------------------------------------------------------
-
- def __getSessionManager (self):
-
- if self._server is None:
- params = {'host' : self.parameters.get ('host'),
- 'port' : self.parameters.get ('port'),
- 'transport': self.parameters.get ('transport')}
- rpcType = self.parameters.get ('rpctype')
- self._server = client.attach (rpcType, params)
-
- if self.parameters.has_key ('timeout'):
- self._server.setTimeout (float (self.parameters ['timeout']))
-
- if self._sm is None:
- self._sm = self._server.request ('Session')
-
- return self._sm
-
-
- # ---------------------------------------------------------------------------
- # Update the given filter values
- # ---------------------------------------------------------------------------
-
- def __updateFilters (self, connectData):
-
- for item in self._filters:
- (filterId, filterLabel) = item [0]
-
- if connectData.has_key (filterId):
- value = connectData [filterId]
- (label, search, field) = item [1][0]
-
- # if there are no filter values we've to skip replacement. Maybe the
- # user just wants to add new filter values
- if not len (item [3].keys ()):
- continue
-
- if item [2] is None:
- masterkey = None
- else:
- masterkey = connectData [item [2]]
-
- found = False
- vDict = item [3][masterkey]
- for record in vDict:
- if record [field] == value:
- connectData [filterId] = record ['gnue_id']
- found = True
- break
-
- if not found:
- raise Exceptions.LoginError, \
- u_("'%(value)s' is not a valid filter-value for '%(filter)s'") \
- % {'value': value,
- 'filter': label}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7165 - trunk/gnue-common/src/datasources/drivers/appserver/appserver,
reinhard <=