use manage_afterAdd() to rename unique ID after object is created

classic Classic list List threaded Threaded
3 messages Options
Rhonda Shirah Rhonda Shirah
Reply | Threaded
Open this post in threaded view
|

use manage_afterAdd() to rename unique ID after object is created

Message
I need to create a unique ID for an object created through Archetypes.  The ID needs to contain information from 3 different fields on the form.  These fields are not populated until after the user does so.  Therefore, the fields are not accessible until after creation of the object. 
 
I read that I can use manage_afterAdd() to rename an object after it has been created.  I can't find any good examples of how this works.  Does anyone know where I can find good/detailed documentation on how to do this? 
 
Thanks,
Rhonda 
Sam Allgood Sam Allgood
Reply | Threaded
Open this post in threaded view
|

Re: use manage_afterAdd() to rename unique ID after object is created

Rhonda Shirah wrote:

> I need to create a unique ID for an object created through Archetypes.  
> The ID needs to contain information from 3 different fields on the
> form.  These fields are not populated until after the user does so.  
> Therefore, the fields are not accessible until after creation of the
> object.
>  
> I read that I can use manage_afterAdd() to rename an object after it has
> been created.  I can't find any good examples of how this works.  Does
> anyone know where I can find good/detailed documentation on how to do this?
>  
> Thanks,
> Rhonda

I just use the setId method and reassign the id to the desired values,
calling it in a post_validate method (called automatically after editing):

     def post_validate(self, REQUEST, errors):
         self.setId(self.getLastName() + self.getFirstName().replace('
','') + "-" + self.getContactType())



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Luca Olivetti-4 Luca Olivetti-4
Reply | Threaded
Open this post in threaded view
|

Re: use manage_afterAdd() to rename unique ID after object is created

In reply to this post by Rhonda Shirah
En/na Rhonda Shirah ha escrit:
> I need to create a unique ID for an object created through Archetypes.  
> The ID needs to contain information from 3 different fields on the
> form.  These fields are not populated until after the user does so.  
> Therefore, the fields are not accessible until after creation of the
> object.

If it's enough to do it just once, after the object has been created see:
http://plone.org/documentation/tutorial/richdocument/controlling-creation

Bye
--
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004      Fax +34 93 5883007


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users