[zope2-tracker] [Bug 423171] [NEW] External Method-1-0-0 returns 404 Error when module name or function name has a trailing space

Mark Phillips mark at phillipsmarketing.biz
Wed Sep 2 09:17:42 EDT 2009


Public bug reported:

When filling out the Add External Method form, it is possible to include
leading or trailing spaces in the module or function name. If either or
both names have a leading/trailing space, the Add External Method
returns and error 404 - the function or module cannot be found. It is
easy for a user to incorporate a trailing space by either typing the
names or cutting and pasting the names from another source.

An example stack trace with a space after the module name:
Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 59, in manage_addExternalMethod
  Module Products.ExternalMethod.ExternalMethod, line 111, in __init__
  Module Products.ExternalMethod.ExternalMethod, line 134, in manage_edit
  Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction
  Module App.Extensions, line 120, in getObject
NotFound: The specified module, <em>WorkflowEmailScripts </em>, couldn't be found.

An example stack trace with a trailing space after the function name:
Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 59, in manage_addExternalMethod
  Module Products.ExternalMethod.ExternalMethod, line 111, in __init__
  Module Products.ExternalMethod.ExternalMethod, line 134, in manage_edit
  Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction
  Module App.Extensions, line 158, in getObject
   - __traceback_info__: ('/opt/Plone-2.5.5/zeocluster/client1/Extensions/WorkflowEmailScripts.py', 'WorkflowEmailScripts')
NotFound: The specified object, <em>edit_new_content </em>, was not found in module, <em>WorkflowEmailScripts</em>.

Suggested Solution:
In Products.ExternalMethod.py these lines -
    56     module=str(module)
    57     function=str(function)

should be changed to
    56     module=str(module).strip()
    57     function=str(function).strip()

It may be a good idea to make these changes as well:
     54     id=str(id)
     55     title=str(title)

     54     id=str(id).strip()
     55     title=str(title).strip()

This bug is easy to reproduce:
1. Create an python script with one function
2. Add the script to the Extensions directory
3. Go to the ZMI
4. Select Add External Method
5. Type the Id, Title, Module name for the python script, and Function name in the python script
6. Add a trailing or leading space to either the Function name or Module name
7 Click Add, and you will get a 404 error and the stack trace above.
8. Remove the trailing or leading space and the External method will be loaded correctly.

** Affects: zope2
     Importance: Undecided
         Status: New

-- 
External Method-1-0-0 returns 404 Error when module name or function name has a trailing space
https://bugs.launchpad.net/bugs/423171
You received this bug notification because you are a member of Zope 2
Developers, which is subscribed to Zope 2.


More information about the zope2-tracker mailing list