commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8424 - in trunk/gnue-common/src/logic: . adapters


From: reinhard
Subject: [gnue] r8424 - in trunk/gnue-common/src/logic: . adapters
Date: Wed, 19 Apr 2006 01:55:59 -0500 (CDT)

Author: reinhard
Date: 2006-04-19 01:55:58 -0500 (Wed, 19 Apr 2006)
New Revision: 8424

Modified:
   trunk/gnue-common/src/logic/GTrigger.py
   trunk/gnue-common/src/logic/adapters/Base.py
   trunk/gnue-common/src/logic/adapters/python.py
   trunk/gnue-common/src/logic/language.py
Log:
Epydoc fixes, and a much better solution to the "self" name clash problem.

Issue75 testing


Modified: trunk/gnue-common/src/logic/GTrigger.py
===================================================================
--- trunk/gnue-common/src/logic/GTrigger.py     2006-04-19 06:31:10 UTC (rev 
8423)
+++ trunk/gnue-common/src/logic/GTrigger.py     2006-04-19 06:55:58 UTC (rev 
8424)
@@ -322,7 +322,7 @@
           # TODO: do we need to call "updateNamespace" here?
           #   function.updateNamespace()
           try:
-            return function(__self = self._namespace_object)
+            return function(self = self._namespace_object)
           except language.AbortRequest:
             if not ignoreAbort:
               raise

Modified: trunk/gnue-common/src/logic/adapters/Base.py
===================================================================
--- trunk/gnue-common/src/logic/adapters/Base.py        2006-04-19 06:31:10 UTC 
(rev 8423)
+++ trunk/gnue-common/src/logic/adapters/Base.py        2006-04-19 06:55:58 UTC 
(rev 8424)
@@ -51,9 +51,10 @@
 
 class LanguageAdapter:
     """
-    Base class for language adapters.
+    Base class for language adapters. DEPRECIATED.
 
-    Descendants must implement the L{createNewContext} function.
+    This class will be depreciated in 0.7 and removed in 0.8.
+    Depreciated. Use L{language.create_execution_context} instead.
     """
 
     # -------------------------------------------------------------------------
@@ -63,9 +64,13 @@
     def createNewContext(self):
         """
         Create a new execution context in which user provided code can run.
+        DEPRECIATED.
 
+        This function will be depreciated in 0.7 and removed in 0.8.
+        Use L{language.create_execution_context} instead.
+
         @return: Execution context object.
-        @rtype: L{ExecutionContext}
+        @rtype: ExecutionContext
         """
         raise ImplementationError, (self.__class__, 'createNewContext()')
 

Modified: trunk/gnue-common/src/logic/adapters/python.py
===================================================================
--- trunk/gnue-common/src/logic/adapters/python.py      2006-04-19 06:31:10 UTC 
(rev 8423)
+++ trunk/gnue-common/src/logic/adapters/python.py      2006-04-19 06:55:58 UTC 
(rev 8424)
@@ -235,24 +235,21 @@
     # Execute the function
     # -------------------------------------------------------------------------
 
-    def __call__(self, *args, **params):
+    def __call__(__self, *args, **params):
         """
         This function creates a local namespace as a copy from the execution
         context's local namespace, adds all parameters to this namespace and
         executes the code.
         """
 
-        # Change '__self' parameter to 'self'
-        parameters = params.copy()
-        if parameters.has_key('__self'):
-            parameters['self'] = parameters['__self']
-            del parameters['__self']
+        # We call our own self parameter "__self" here so that the user
+        # function can have a parameter "self".
 
-        self.__local_namespace['__parameters'] = parameters
+        __self.__local_namespace['__parameters'] = params
 
         try:
-            exec self.__compiled_code \
-                    in self.__global_namespace, self.__local_namespace
+            exec __self.__compiled_code \
+                    in __self.__global_namespace, __self.__local_namespace
 
         except language.AbortRequest:
             # Pass through AbortRequests unchanged
@@ -265,4 +262,4 @@
                 group = 'application'
             raise language.RuntimeError, (group, name, message, detail)
 
-        return self.__local_namespace.get('__result')
+        return __self.__local_namespace.get('__result')

Modified: trunk/gnue-common/src/logic/language.py
===================================================================
--- trunk/gnue-common/src/logic/language.py     2006-04-19 06:31:10 UTC (rev 
8423)
+++ trunk/gnue-common/src/logic/language.py     2006-04-19 06:55:58 UTC (rev 
8424)
@@ -38,7 +38,8 @@
 from gnue.common.utils.FileUtils import dyn_import
 
 __all__ = ['AdapterNotFoundError', 'ImplementationError', 'CompileError',
-        'RuntimeError', 'AbortRequest', 'getLanguageAdapter']
+        'RuntimeError', 'AbortRequest', 'getLanguageAdapter',
+        'create_execution_context']
 
 __plugins = {}                          # Cache for loaded plugins
 
@@ -77,7 +78,8 @@
     Error in user code compilation.
 
     An error occured when trying to compile user code. Details of the error are
-    available through the L{getName}, {getDatail}, and {getMessage} methods.
+    available through the L{getName}, L{getDatail}, and L{getMessage}
+    methods.
     """
     pass
 
@@ -88,7 +90,8 @@
     Error in user code execution.
 
     An error occured when trying to execute user code. Details of the error are
-    available through the L{getName}, {getDatail}, and {getMessage} methods.
+    available through the L{getName}, L{getDatail}, and L{getMessage}
+    methods.
     """
     pass
 
@@ -137,8 +140,8 @@
         builtins to the user code, which means that they can even be accessed
         from modules that are imported into the user code.
     @type builtin_namespace: dict
-    @return The execution context that can be used to run user defined code.
-    @rtype L{adapters.Base.ExecutionContext}
+    @return: The execution context that can be used to run user defined code.
+    @rtype: L{adapters.Base.ExecutionContext}
     """
 
     checktype(language, basestring)
@@ -175,7 +178,7 @@
     @type language: string or unicode
 
     @return: Language adapter object
-    @rtype: L{adapters.Base.LanguageAdapter}
+    @rtype: adapters.Base.LanguageAdapter
 
     @raise AdapterNotFoundError: There is no language adapter available for the
         given language.





reply via email to

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