[Product-Developers] Rename an object after it has been added
Andreas Jung
lists at zopyx.com
Wed Jul 27 08:30:55 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The error message is self-speaking. You are trying to rename an object
to some id which already exists inside the same folder.
- -aj
imran.azad wrote:
> I want to rename the id or the 'short name' as soon as an object is
> either added or modified. I have managed to achieve this via the code
> below:
>
> @grok.subscribe(IPerson, IObjectModifiedEvent)
>
> def rename(person, event): parent = person.aq_parent
> parent.manage_renameObject(person.getId(), str(person.title))
>
> However, the code only works for when an object is modified not when
> an object is created. When an object is created it throws the
> following error:
>
> The id "test test" is invalid - it is already in use.
>
> I have checked and there is no id "test test" that is in use.
>
> Here is the more consice error: Traceback (innermost last): Module
> ZPublisher.Publish, line 127, in publish Module ZPublisher.mapply,
> line 77, in mapply Module ZPublisher.Publish, line 47, in
> call_object Module plone.z3cform.layout, line 64, in __call__ Module
> plone.z3cform.layout, line 54, in update Module
> plone.z3cform.fieldsets.extensible, line 59, in update Module
> plone.z3cform.patch, line 30, in GroupForm_update Module
> z3c.form.group, line 138, in update Module z3c.form.action, line 99,
> in execute Module z3c.form.button, line 311, in __call__ Module
> z3c.form.button, line 170, in __call__ Module
> plone.dexterity.browser.add, line 93, in handleAdd Module
> z3c.form.form, line 247, in createAndAdd Module
> plone.dexterity.browser.add, line 72, in add Module
> plone.dexterity.utils, line 145, in addContentToContainer Module
> Products.BTreeFolder2.BTreeFolder2, line 450, in _setObject Module
> zope.event, line 23, in notify Module zope.component.event, line 26,
> in dispatch Module zope.component._api, line 138, in subscribers
> Module zope.component.registry, line 323, in subscribers Module
> zope.interface.adapter, line 575, in subscribers Module
> zope.component.event, line 33, in objectEventNotify Module
> zope.component._api, line 138, in subscribers Module
> zope.component.registry, line 323, in subscribers Module
> zope.interface.adapter, line 575, in subscribers Module
> bthft.eprs.person, line 29, in createCategories Module
> plone.dexterity.utils, line 150, in createContentInContainer Module
> plone.dexterity.utils, line 145, in addContentToContainer Module
> Products.BTreeFolder2.BTreeFolder2, line 451, in _setObject Module
> zope.container.contained, line 329, in notifyContainerModified Module
> zope.event, line 23, in notify Module zope.component.event, line 26,
> in dispatch Module zope.component._api, line 138, in subscribers
> Module zope.component.registry, line 323, in subscribers Module
> zope.interface.adapter, line 575, in subscribers Module
> zope.component.event, line 33, in objectEventNotify Module
> zope.component._api, line 138, in subscribers Module
> zope.component.registry, line 323, in subscribers Module
> zope.interface.adapter, line 575, in subscribers Module
> bthft.eprs.person, line 38, in rename Module plone.folder.ordered,
> line 187, in manage_renameObject Module OFS.CopySupport, line 350, in
> manage_renameObject CopyError: <HTML> <HEAD> <TITLE>Invalid
> Id</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <FORM
> ACTION="manage_main" METHOD="GET" > <TABLE BORDER="0" WIDTH="100%"
> CELLPADDING="10"> <TR> <TD VALIGN="TOP"> <BR> <CENTER>!</CENTER>
> </TD> <TD VALIGN="TOP"> <BR><BR> <CENTER> The id "test test" is
> invalid - it is already in use. </CENTER> </TD> </TR> <TR> <TD
> VALIGN="TOP"> </TD> <TD VALIGN="TOP"> <CENTER> <INPUT TYPE="SUBMIT"
> VALUE=" Ok "> </CENTER> </TD> </TR> </TABLE> </FORM>
> </BODY></HTML>
>
>
> -- View this message in context:
> http://plone.293351.n2.nabble.com/Rename-an-object-after-it-has-been-added-tp6625176p6625176.html
>
>
Sent from the Product Developers mailing list archive at Nabble.com.
> _______________________________________________ Product-Developers
> mailing list Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers
- --
ZOPYX Limited | zopyx group
Charlottenstr. 37/1 | The full-service network for Zope & Plone
D-72070 Tübingen | Produce & Publish
www.zopyx.com | www.produce-and-publish.com
- ------------------------------------------------------------------------
E-Publishing, Python, Zope & Plone development, Consulting
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJOL8y+AAoJEADcfz7u4AZjweILwNMxkAlGFIxhJse7JUFFVuUU
orC/YMrZvcHJs3I+UvoXp0hsCvKP7mCtMJYsU+xTGXzyE4gDm6oiP46+Qzlw3TkK
xS8Nd/AWgMngv5RexJONEYwS9N+To1ufctE5imfx1GFzBN+Mkr3Zfl1hr5YnDjQB
E8yqadLlugxn8wgSHKuA1IxA97DuDaXtzvZtTtnSV3tOihJ9tWqVl9HZ5bzJL3cG
KIBEg3BKiLcEu/wjBbm2euPmu3EHCxadwkZR9Z5RBoyoOzE+HpeNQRz9rNMQu2s1
vI3VFR7q6bFu1XLe222vmeryCSRDhtnCTTLqXq+l1Es+PcPysytqmoPu5pvVIwNF
nlixGlFkiBUxKv10/8DNLNS/2A2+AAtlr26Psmaac7OMfqDmiPgIgG19/8SXqonR
k2Pu/iEG5ytinlXJtISZCxvENSpZjWPsGBi/jaGGQjvMxp4y84Cf8MkW8qE7tDAj
rLFK0UKs/iYycupZVLzIezWvoAw3ZvA=
=llIy
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 310 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110727/cf147e36/attachment-0001.vcf>
More information about the Product-Developers
mailing list