Ticket #8338 (confirmed Bug)

Opened 8 years ago

Last modified 4 years ago

creation of new content with space at the end of shortname raises exception

Reported by: mjr66 Owned by: nouri
Priority: minor Milestone: 4.x
Component: Archetypes Version: 4.2
Keywords: patch Cc: stxnext

Description

Using Plone 3.1.2 (installed with Universal Installer), if you create a new content item (any type) and accidentally include a space at the end of the shortname (easily done if copying and pasting text), then the following exception is raised when you try to save the file (which I tried to call "whoops " in the following example) -

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFPlone.FactoryTool, line 376, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 28, in _call
  Module Products.CMFFormController.ControllerBase, line 231, in getNext
  Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPythonScript, line 106, in __call__
  Module Products.CMFFormController.ControllerBase, line 231, in getNext
  Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPythonScript, line 104, in __call__
  Module Products.CMFFormController.Script, line 145, in __call__
  Module Products.CMFCore.FSPythonScript, line 140, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 196, in _exec
  Module None, line 1, in content_edit
   - <FSControllerPythonScript at /Plone/content_edit used for /Plone/portal_factory/File/file.2008-07-30.4628605229>
   - Line 1
  Module Products.CMFCore.FSPythonScript, line 140, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 196, in _exec
  Module None, line 13, in content_edit_impl
   - <FSPythonScript at /Plone/content_edit_impl used for /Plone/portal_factory/File/file.2008-07-30.4628605229>
   - Line 13
  Module Products.Archetypes.BaseObject, line 661, in processForm
  Module Products.Archetypes.BaseObject, line 651, in _processForm
   - __traceback_info__: (<ATFile at /Plone/whoops>, <Field id(string:rw)>, <bound method ATFile.setId of <ATFile at /Plone/whoops>>)
  Module Products.Archetypes.utils, line 162, in mapply
  Module Products.Archetypes.BaseObject, line 216, in setId
  Module Products.CMFPlone.PloneFolder, line 197, in manage_renameObject
  Module OFS.CopySupport, line 344, in manage_renameObject
Copy Error:
<HTML>
<HEAD>
<TITLE>Not Supported</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM ACTION="manage_main" METHOD="GET" >
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="10">
<TR>
  <TD VALIGN="TOP">
  <BR>
  <CENTER><B><FONT SIZE="+6" COLOR="#77003B">!</FONT></B></CENTER>
  </TD>
  <TD VALIGN="TOP">
  <BR><BR>
  <CENTER>
  The action against the <em>whoops</em> object could not be carried out. One of
the following constraints caused the problem: <br><br>The object does not
support this operation.<br><br>-- OR --<br><br>The currently logged-in user does
not have the <b>Copy or Move</b> permission respective to the object.
  </CENTER>
  </TD>
</TR>
<TR>
  <TD VALIGN="TOP">
  </TD>
  <TD VALIGN="TOP">
  <CENTER>
  <INPUT TYPE="SUBMIT" VALUE="   Ok   ">
  </CENTER>
  </TD>
</TR>
</TABLE>
</FORM>
</BODY></HTML>

Attachments

Archetypes.BaseObject.py.diff Download (2.2 KB) - added by stxnext 8 years ago.

Change History

comment:1 Changed 8 years ago by stxnext

  • Cc stxnext added

After quite long investigation, now I know the reason why it raises CopyError exception:

  1. User create object (in portal_factory)
  2. User submits add form (shortname has space at end)
  3. FactoryTool creates real object with stripped id (see: 'doCreate' method in CMFPlone/FactoryTool.py, line 253)
  4. 'processForm' applying data from form and trying to set id (id not stripped)
  5. Bacause id != id.strip() it try to rename object
  6. 'manage_renameObject' raises 'CopyError' because object is not commited to ZODB

It was hard to debug, but solution is trivial ;)

Patch for Archetypes/BaseObject (with test) attached.

Changed 8 years ago by stxnext

comment:2 Changed 7 years ago by limi

  • Owner set to nouri
  • Component changed from Unknown to Archetypes

comment:3 Changed 4 years ago by kleist

  • Status changed from new to confirmed
  • Keywords patch added
  • Version set to 4.2
  • Milestone changed from 3.3.x to 4.x

Still bails out in Plone 4.2 coredev buildout.

comment:4 Changed 4 years ago by kleist

Fixed by  https://github.com/plone/Products.Archetypes/commit/2a85c06077e1b1d5c91fe69b173380b364a3fb36.

But I haven't created the test method. One step forward, anybody?

Note: See TracTickets for help on using tickets.