commit-gnue
[Top][All Lists]
Advanced

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

r5575 - trunk/gnue-common/src/logic/adapters


From: reinhard
Subject: r5575 - trunk/gnue-common/src/logic/adapters
Date: Tue, 30 Mar 2004 07:33:27 -0600 (CST)

Author: reinhard
Date: 2004-03-30 07:33:26 -0600 (Tue, 30 Mar 2004)
New Revision: 5575

Modified:
   trunk/gnue-common/src/logic/adapters/python.py
Log:
Fix for triggers with non-letters in trigger name.


Modified: trunk/gnue-common/src/logic/adapters/python.py
===================================================================
--- trunk/gnue-common/src/logic/adapters/python.py      2004-03-30 11:57:56 UTC 
(rev 5574)
+++ trunk/gnue-common/src/logic/adapters/python.py      2004-03-30 13:33:26 UTC 
(rev 5575)
@@ -20,9 +20,10 @@
 #
 # $Id: $
 
-from string import join
 from copy import copy
 
+import string
+
 from gnue.common.logic import language
 from gnue.common.logic.adapters import Base
 
@@ -134,13 +135,16 @@
     Preparing a sourcecode for python means compiling. This function compiles
     the code.
     """
-    # if name has invalid characters, we won't use it as function name
-    if 1 in [c in self._name for c in " ."]:
-      self.funcName = "tempCode"
-    else:
-      self.funcName = self._name
+    # The function name may only contain ascii characters and underscores.
+    self.funcName = ''
+    for c in self._name:
+      # if c in string.ascii_letters:  -- needs Python 2.2 or later
+      if c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz':
+        self.funcName += c
+      else:
+        self.funcName += '_'
 
-    paramlist = join (['__namespace'] + self._parameters.keys (), ", ")
+    paramlist = string.join (['__namespace'] + self._parameters.keys (), ", ")
     text      = self._code.rstrip ()
 
     try:





reply via email to

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