Re: [Zope-dev] How to create a product with all_meta_types and the name of the product
Hi Chris! Want I want exactly is to create a product's object by his name programmatically not by the construction form Is this posible? Thanks!!! - Original Message - From: Chris Withers [EMAIL PROTECTED] To: Garito [EMAIL PROTECTED] Cc: Lista Oficial de Zope [EMAIL PROTECTED] Sent: Friday, March 12, 2004 9:37 AM Subject: Re: [Zope-dev] How to create a product with all_meta_types and the name of the product Garito wrote: In the information retrieved by self.all_meta_types()['product']['action'] I can retrive the 'manage_addProduct' string, 'product' string but I don't retrieve manage_addMyProductManageAdd but I retrieve manage_addMyProductManageAddForm (this is the form of the constructor) Any idea? Loose the HTML encoding in your mails for starters ;-) The ngo find the code which builds the Add dropdown in the ZMI, since that appears to do what you want... Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] How to create a product with all_meta_types and the name of the product
Garito wrote: In the information retrieved by self.all_meta_types()['product']['action'] I can retrive the 'manage_addProduct' string, 'product' string but I don't retrieve manage_addMyProductManageAdd but I retrieve manage_addMyProductManageAddForm (this is the form of the constructor) Any idea? Loose the HTML encoding in your mails for starters ;-) The ngo find the code which builds the Add dropdown in the ZMI, since that appears to do what you want... Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] How to create a product with all_meta_types and the
Garito wrote: Hi Chris! Want I want exactly is to create a product's object by his name programmatically not by the construction form Is this posible? You cannot know the name of the constructor function, unless you read the source. The constructors added to Zope during the product initialisation can be both forms and actual function methods. There is no way of knowing which. And there can be more than two. So you would need to write a factory function based on the info you can get from the source. Ie. in an external method. Something like:: def portal_factory(self, parent, portal_type, id='', title='',): Adds the content. A factory function. # generate a general id if id == '': id = self.ZopeTime().strftime(portal_type + '_%Y%m%d_%H%M%S') zope_factory = parent.manage_addProduct # add the content if 'Document' == portal_type: zope_factory['Document'].manage_addDocumentAction(id) elif 'Some Type' == portal_type: zope_factory['Some Type'].manage_addSomeTypeAction(id) else: raise 'Error adding portal_type' # get the newly added content obj = getattr(parent, id) # Add the title obj.title = title return obj -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] How to create a product with all_meta_types and the
Hi Max I understand what you explain but what about if I install a new product? Rewrite the factory? I think is not a good solution don't you think? Thanks!! - Original Message - From: Max M [EMAIL PROTECTED] To: Garito [EMAIL PROTECTED] Cc: Lista Oficial de Zope [EMAIL PROTECTED] Sent: Friday, March 12, 2004 10:34 AM Subject: Re: [Zope-dev] How to create a product with all_meta_types and the Garito wrote: Hi Chris! Want I want exactly is to create a product's object by his name programmatically not by the construction form Is this posible? You cannot know the name of the constructor function, unless you read the source. The constructors added to Zope during the product initialisation can be both forms and actual function methods. There is no way of knowing which. And there can be more than two. So you would need to write a factory function based on the info you can get from the source. Ie. in an external method. Something like:: def portal_factory(self, parent, portal_type, id='', title='',): Adds the content. A factory function. # generate a general id if id == '': id = self.ZopeTime().strftime(portal_type + '_%Y%m%d_%H%M%S') zope_factory = parent.manage_addProduct # add the content if 'Document' == portal_type: zope_factory['Document'].manage_addDocumentAction(id) elif 'Some Type' == portal_type: zope_factory['Some Type'].manage_addSomeTypeAction(id) else: raise 'Error adding portal_type' # get the newly added content obj = getattr(parent, id) # Add the title obj.title = title return obj -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] How to create a product with all_meta_types and the
Garito wrote: Hi Max I understand what you explain but what about if I install a new product? Rewrite the factory? I think is not a good solution don't you think? No, but I don't see any way around it. I could be wrong, though I don't think so. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] How to create a product with all_meta_types and the name of the product
Hi all I would like to create a product knowing the name of these product. How to do it? I arrive to product but I don't know how to create it and set to de container With these code self['manage_addProduct']['product'].manage_addMyProductManageAdd(id, content) In the information retrieved by self.all_meta_types()['product']['action']I can retrivethe 'manage_addProduct' string, 'product' string but Idon'tretrieve manage_addMyProductManageAdd but Iretrievemanage_addMyProductManageAddForm (this is the form of the constructor) Any idea? Thanks ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )