[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r6019 - in trunk/gnue-common/src: apps datasources
From: |
jcater |
Subject: |
r6019 - in trunk/gnue-common/src: apps datasources |
Date: |
Wed, 21 Jul 2004 17:12:27 -0500 (CDT) |
Author: jcater
Date: 2004-07-21 17:12:26 -0500 (Wed, 21 Jul 2004)
New Revision: 6019
Modified:
trunk/gnue-common/src/apps/plugin.py
trunk/gnue-common/src/datasources/GConnections.py
Log:
Added a caching mechanism to the plugin system to speed up multiple loading of
the same providers
Modified: trunk/gnue-common/src/apps/plugin.py
===================================================================
--- trunk/gnue-common/src/apps/plugin.py 2004-07-21 22:09:17 UTC (rev
6018)
+++ trunk/gnue-common/src/apps/plugin.py 2004-07-21 22:12:26 UTC (rev
6019)
@@ -154,8 +154,14 @@
_base = base.encode ()
_identifier = identifier.encode ()
- # Now search the plugin
- result = __find (_base, _name, _identifier)
+ # First, see if we've already found this module previously
+ global __findCache
+ try:
+ result = __findCache[(_base, _name)]
+ except KeyError:
+ # If not, search for the plugin
+ result = __findCache[(_base, _name)] = __find (_base, _name, _identifier)
+
if isinstance (result, ModuleType):
return result
else:
@@ -171,6 +177,11 @@
__failed = {}
# -----------------------------------------------------------------------------
+# Mapping of previously found plugins
+# -----------------------------------------------------------------------------
+__findCache = {}
+
+# -----------------------------------------------------------------------------
# Find all modules and subpackages in a package
# -----------------------------------------------------------------------------
@@ -240,7 +251,7 @@
def __first (base, identifier):
- global __failed
+ global __failed
if __failed.has_key (base):
# This has already failed in previous attempt
Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py 2004-07-21 22:09:17 UTC
(rev 6018)
+++ trunk/gnue-common/src/datasources/GConnections.py 2004-07-21 22:12:26 UTC
(rev 6019)
@@ -209,7 +209,7 @@
# ---------------------------------------------------------------------------
- # get a connection instance on optionally log into it
+ # get a connection instance on optionally log into it
# ---------------------------------------------------------------------------
def getConnection (self, connection_name, login = False):
@@ -251,7 +251,7 @@
# Check for the case that a "Connection" is passed instead of a
# "Connection" class. This is the case, when the procedure for deferal of
# the loading of the connection object is overwriten by the "connection"
- # module. i.e. there is a Connection.py file
+ # module. i.e. there is a Connection.py file
# TODO: remove this extra check by cleaning up the whole loading
# procedure
conn = dbdriver.Connection.Connection (self, connection_name, parameters)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r6019 - in trunk/gnue-common/src: apps datasources,
jcater <=