[open-ils-commits] r8329 - branches/acq-experiment/Open-ILS/src/python/oils/utils

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Jan 6 14:35:48 EST 2008


Author: dbs
Date: 2008-01-06 14:11:38 -0500 (Sun, 06 Jan 2008)
New Revision: 8329

Modified:
   branches/acq-experiment/Open-ILS/src/python/oils/utils/idl.py
Log:
Enable subscripted access to attributes (requirement for Python 2.4 support, perhaps?)


Modified: branches/acq-experiment/Open-ILS/src/python/oils/utils/idl.py
===================================================================
--- branches/acq-experiment/Open-ILS/src/python/oils/utils/idl.py	2008-01-06 19:09:51 UTC (rev 8328)
+++ branches/acq-experiment/Open-ILS/src/python/oils/utils/idl.py	2008-01-06 19:11:38 UTC (rev 8329)
@@ -159,6 +159,14 @@
         else:
             self.virtual = False
 
+    def __getitem__(self, member):
+        """
+        Returns the requested member using dictionary syntax.
+        """
+        if hasattr(self, member):
+            exec("result = self.%s" % member)
+            return result
+
     def get_field(self, field_name):
         try:
             return [f for f in self.fields if f.name == field_name][0]
@@ -186,6 +194,13 @@
         else:
             self.virtual = False
 
+    def __getitem__(self, member):
+        """
+        Returns the requested member using dictionary syntax.
+        """
+        if hasattr(self, member):
+            exec("result = self.%s" % member)
+            return result
 
 class IDLLink(object):
     def __init__(self, field, **kwargs):



More information about the open-ils-commits mailing list