[Checkins] SVN: Products.ExternalMethod/trunk/src/Products/ExternalMethod/ Cleanup

Hanno Schlichting hannosch at hannosch.eu
Sat Jul 10 05:29:34 EDT 2010


Log message for revision 114482:
  Cleanup
  

Changed:
  D   Products.ExternalMethod/trunk/src/Products/ExternalMethod/CHANGES.txt
  U   Products.ExternalMethod/trunk/src/Products/ExternalMethod/ExternalMethod.py
  D   Products.ExternalMethod/trunk/src/Products/ExternalMethod/README.txt
  U   Products.ExternalMethod/trunk/src/Products/ExternalMethod/__init__.py
  U   Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/Extensions/Test.py
  U   Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/__init__.py
  U   Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/testExternalMethod.py
  D   Products.ExternalMethod/trunk/src/Products/ExternalMethod/version.txt

-=-
Deleted: Products.ExternalMethod/trunk/src/Products/ExternalMethod/CHANGES.txt
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/CHANGES.txt	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/CHANGES.txt	2010-07-10 09:29:34 UTC (rev 114482)
@@ -1,53 +0,0 @@
-External Method Changes
-
-  External Method 1.3
-  
-    Features
-  
-     - Permissions have been updated to work with the Principia 1.2 and
-       later permission-management enhancements.
-  
-  
-  External Method 1.2
-  
-    Bug Fixes
-  
-      - TypeError exceptions in external methods were reported
-	incorrectly. 
-  
-    Features
-  
-      - ExternalMethods now use standard_error_message to report errors.
-  
-  
-  External Method 1.1
-  
-    This release changes the way that ExternalMethods are bound to 
-    folders.  ExternalMethods now bind themselves to their acquisition
-    parents, rather than to REQUEST['PARENTS'][0].  This is needed to
-    make ExternalMethods useful in trees and exprs.  The 1.1 release of
-    Principia is needed for this release of ExternalMethod to
-    function correctly.
-  
-
-  External Method 1.0.3
-  
-    Bugs Fixed
-  
-     - A new copy of an external method was written the first time
-       it was used after being loaded from the database.  In addition to
-       database bloat, this could also cause strange session/locking behavior.
-  
-  
-  External Method 1.0.2
-  
-    Bugs Fixed
-  
-      - Add permissions were not editable.
-  
-    Features
-	
-      - If an ExternalMethod takes a single argument, named self, and is
-	called with no arguments, then the folder in which the method
-	is accessed is passed.  This is handy when the method is called 
-	from a document.

Modified: Products.ExternalMethod/trunk/src/Products/ExternalMethod/ExternalMethod.py
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/ExternalMethod.py	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/ExternalMethod.py	2010-07-10 09:29:34 UTC (rev 114482)
@@ -15,12 +15,10 @@
 This product provides support for external methods, which allow
 domain-specific customization of web environments.
 """
-__version__='$Revision: 1.52 $'[11:-2]
 
 import os
 import stat
 import sys
-import traceback
 
 from AccessControl.class_init import InitializeClass
 from AccessControl.Permissions import change_external_methods
@@ -29,21 +27,19 @@
 from AccessControl.SecurityInfo import ClassSecurityInfo
 from Acquisition import Acquired
 from Acquisition import Explicit
-from App.Dialogs import MessageDialog
 from App.Extensions import getObject
 from App.Extensions import getPath
 from App.Extensions import FuncCode
 from App.special_dtml import DTMLFile
-from App.special_dtml import HTML
 from OFS.role import RoleManager
 from OFS.SimpleItem import Item
-from OFS.SimpleItem import pretty_tb
 from Persistence import Persistent
 from App.Management import Navigation
 from ComputedAttribute import ComputedAttribute
 
 manage_addExternalMethodForm=DTMLFile('dtml/methodAdd', globals())
 
+
 def manage_addExternalMethod(self, id, title, module, function, REQUEST=None):
     """Add an external method to a folder
 
@@ -64,23 +60,24 @@
         However, the file name may have a prefix of
         'product.', indicating that it should be found in a product
         directory.
-        
+
         For example, if the module is: 'ACMEWidgets.foo', then an
         attempt will first be made to use the file
         'lib/python/Products/ACMEWidgets/Extensions/foo.py'. If this
         failes, then the file 'Extensions/ACMEWidgets.foo.py' will be
         used.
     """
-    id=str(id)
-    title=str(title)
-    module=str(module)
-    function=str(function)
+    id = str(id)
+    title = str(title)
+    module = str(module)
+    function = str(function)
 
-    i=ExternalMethod(id,title,module,function)
-    self._setObject(id,i)
+    i = ExternalMethod(id, title, module, function)
+    self._setObject(id, i)
     if REQUEST is not None:
-        return self.manage_main(self,REQUEST)
+        return self.manage_main(self, REQUEST)
 
+
 class ExternalMethod(Item, Persistent, Explicit,
                      RoleManager, Navigation):
     """Web-callable functions that encapsulate external python functions.
@@ -108,17 +105,16 @@
     func_defaults = ComputedAttribute(lambda self: self.getFuncDefaults())
     func_code = ComputedAttribute(lambda self: self.getFuncCode())
 
-
     ZopeTime = Acquired
     HelpSys = Acquired
     manage_page_header = Acquired
 
     manage_options=(
         (
-        {'label':'Properties', 'action':'manage_main',
-         'help':('ExternalMethod','External-Method_Properties.stx')},
-        {'label':'Test', 'action':'',
-         'help':('ExternalMethod','External-Method_Try-It.stx')},
+        {'label': 'Properties', 'action': 'manage_main',
+         'help': ('ExternalMethod', 'External-Method_Properties.stx')},
+        {'label': 'Test', 'action': '',
+         'help': ('ExternalMethod', 'External-Method_Try-It.stx')},
         )
         + Item.manage_options
         + RoleManager.manage_options
@@ -155,19 +151,19 @@
         self.getFunction(1)
         if REQUEST:
             message="External Method Uploaded."
-            return self.manage_main(self,REQUEST,manage_tabs_message=message)
+            return self.manage_main(self, REQUEST, manage_tabs_message=message)
 
     def getFunction(self, reload=0):
+        f = getObject(self._module, self._function, reload)
+        if hasattr(f, 'im_func'):
+            ff = f.im_func
+        else:
+            ff = f
 
-        f=getObject(self._module, self._function, reload)
-        if hasattr(f,'im_func'): ff=f.im_func
-        else: ff=f
+        self._v_func_defaults = ff.func_defaults
+        self._v_func_code = FuncCode(ff, f is not ff)
+        self._v_f = f
 
-        self._v_func_defaults  = ff.func_defaults
-        self._v_func_code = FuncCode(ff,f is not ff)
-
-        self._v_f=f
-
         return f
 
     def reloadIfChanged(self):
@@ -217,28 +213,27 @@
 
         filePath = self.filepath()
         if filePath==None:
-            raise RuntimeError,\
-                "external method could not be called " \
-                "because it is None"
+            raise RuntimeError("external method could not be called "
+                               "because it is None")
 
         if not os.path.exists(filePath):
-            raise RuntimeError,\
-                "external method could not be called " \
-                "because the file does not exist"
+            raise RuntimeError("external method could not be called "
+                               "because the file does not exist")
 
         if Globals.DevelopmentMode:
             self.reloadIfChanged()
 
         if hasattr(self, '_v_f'):
-            f=self._v_f
+            f = self._v_f
         else:
-            f=self.getFunction()
+            f = self.getFunction()
 
         __traceback_info__=args, kw, self._v_func_defaults
 
-        try: return f(*args, **kw)
+        try:
+            return f(*args, **kw)
         except TypeError, v:
-            tb=sys.exc_info()[2]
+            tb = sys.exc_info()[2]
             try:
                 if ((self._v_func_code.co_argcount-
                      len(self._v_func_defaults or ()) - 1 == len(args))
@@ -246,16 +241,19 @@
                     return f(self.aq_parent.this(), *args, **kw)
 
                 raise TypeError, v, tb
-            finally: tb=None
+            finally:
+                tb = None
 
+    def function(self):
+        return self._function
 
-    def function(self): return self._function
-    def module(self): return self._module
+    def module(self):
+        return self._module
 
     def filepath(self):
         if not hasattr(self, '_v_filepath'):
             self._v_filepath=getPath('Extensions', self._module,
-                                     suffixes=('','py','pyc','pyp'))
+                                     suffixes=('', 'py', 'pyc', 'pyp'))
         return self._v_filepath
 
 InitializeClass(ExternalMethod)

Deleted: Products.ExternalMethod/trunk/src/Products/ExternalMethod/README.txt
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/README.txt	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/README.txt	2010-07-10 09:29:34 UTC (rev 114482)
@@ -1,6 +0,0 @@
-External Methods
-
-
-  The External Method product provides support for external Python
-  methods, exposing them as callable objects within the Zope 
-  environment.

Modified: Products.ExternalMethod/trunk/src/Products/ExternalMethod/__init__.py
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/__init__.py	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/__init__.py	2010-07-10 09:29:34 UTC (rev 114482)
@@ -10,16 +10,11 @@
 # FOR A PARTICULAR PURPOSE
 #
 ##############################################################################
-__doc__='''External Method Product Initialization
-$Id$'''
-__version__='$Revision: 1.15 $'[11:-2]
 
 import ExternalMethod
 
-# This is the new way to initialize products.  It is hoped
-# that this more direct mechanism will be more understandable.
-def initialize(context):
 
+def initialize(context):
     context.registerClass(
         ExternalMethod.ExternalMethod,
         constructors=(ExternalMethod.manage_addExternalMethodForm,

Modified: Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/Extensions/Test.py
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/Extensions/Test.py	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/Extensions/Test.py	2010-07-10 09:29:34 UTC (rev 114482)
@@ -1,4 +1,5 @@
 from math import sqrt
 
-def testf(arg1, sqrt = sqrt):
+
+def testf(arg1, sqrt=sqrt):
     return sqrt(arg1)

Modified: Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/__init__.py
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/__init__.py	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/__init__.py	2010-07-10 09:29:34 UTC (rev 114482)
@@ -11,7 +11,3 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
-
-$Id$
-"""

Modified: Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/testExternalMethod.py
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/testExternalMethod.py	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/tests/testExternalMethod.py	2010-07-10 09:29:34 UTC (rev 114482)
@@ -11,14 +11,10 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
 
-Revision information:
-$Id$
-"""
-
 import math
 import os
+import sys
 import unittest
 
 import ZODB # dead goat
@@ -26,6 +22,19 @@
 from Products.ExternalMethod.ExternalMethod import ExternalMethod
 import App.config
 
+
+def package_home(globals_dict):
+    __name__ = globals_dict['__name__']
+    m = sys.modules[__name__]
+    if hasattr(m, '__path__'):
+        r = m.__path__[0]
+    elif "." in __name__:
+        r = sys.modules[__name__.split('.', 1)[0]].__path__[0]
+    else:
+        r = __name__
+    return os.path.abspath(r)
+
+
 class TestExternalMethod(unittest.TestCase):
 
     def setUp(self):
@@ -45,7 +54,7 @@
         em2 = ExternalMethod.__basicnew__()
         em2.__setstate__(state)
         self.assertEqual(em2(9), math.sqrt(9))
-        self.failIf(state.has_key('func_defaults'))
+        self.failIf('func_defaults' in state)
 
     def test_mapply(self):
         from ZPublisher.mapply import mapply
@@ -58,22 +67,5 @@
         self.assertEqual(mapply(em1, (), {'arg1': 9}), math.sqrt(9))
 
 
-
 def test_suite():
     return unittest.makeSuite(TestExternalMethod)
-
-
-def package_home(globals_dict):
-    __name__=globals_dict['__name__']
-    m=sys.modules[__name__]
-    if hasattr(m,'__path__'):
-        r=m.__path__[0]
-    elif "." in __name__:
-        r=sys.modules[__name__.split('.',1)[0]].__path__[0]
-    else:
-        r=__name__
-    return os.path.abspath(r)
-
-
-if __name__=='__main__':
-    unittest.main(defaultTest='test_suite')

Deleted: Products.ExternalMethod/trunk/src/Products/ExternalMethod/version.txt
===================================================================
--- Products.ExternalMethod/trunk/src/Products/ExternalMethod/version.txt	2010-07-10 09:23:28 UTC (rev 114481)
+++ Products.ExternalMethod/trunk/src/Products/ExternalMethod/version.txt	2010-07-10 09:29:34 UTC (rev 114482)
@@ -1 +0,0 @@
-External Method-1-0-0
\ No newline at end of file



More information about the checkins mailing list