Re[2]: [Zope] Factory-based Type Information
Hello, J. You wrote 21 èþíÿ 2005 ã., 20:27:50: > Denis Mishunoff wrote: >> I have a problem with my product. >> I use Zope 2.7.5 and Plone 2.0.5. >> >> I need to create the copy of Document content-type on my product's >> install the same way as it is done in portal_types via >> "Factory-based Type Information" option of dropdown. >> I just need to have the copy of it and to alter some fields. > Here's some code I stole from Chapter 8 of my book, were a > Folder-derived type is created in an install script:: >from Products.CMFCore.Expression import Expression ># Customize types >types_tool=getToolByName(portal,'portal_types') ># New 'NewsFolder' type based on folder >types_tool.manage_addTypeInformation(id='NewsFolder', > add_meta_type="Factory-based Type Information", > typeinfo_name="CMFPlone: Plone Folder") >nf = getattr(types_tool, 'NewsFolder') >nf.manage_changeProperties(filter_content_types=1, > allowed_content_types=('News Item',)) >actions=nf._cloneActions() >for a in actions: >if a.id == 'view': >a.action = > Expression('string:${object_url}/newsfolder_view') >nf._actions=(actions) > After a clone of the type is made based on Plone Folder, some changes > are made: contents are filtered, and only News Items are allowed; also > an action is changed to point to a custom template. > This is a better option than using the copy/paste API like you might do > in the ZMI. > --jcc Thank you very much, Cameron. Definitelly will use it next time. This time I decided to create the separate content type, because seems like I will need to change some methods of it. But I will definitelly use your solution next time ;) -- Best regards, Denis Mishunoff mailto:[EMAIL PROTECTED] http://plonetarium.objectis.net ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Factory-based Type Information
Denis Mishunoff wrote: I have a problem with my product. I use Zope 2.7.5 and Plone 2.0.5. I need to create the copy of Document content-type on my product's install the same way as it is done in portal_types via "Factory-based Type Information" option of dropdown. I just need to have the copy of it and to alter some fields. Here's some code I stole from Chapter 8 of my book, were a Folder-derived type is created in an install script:: from Products.CMFCore.Expression import Expression # Customize types types_tool=getToolByName(portal,'portal_types') # New 'NewsFolder' type based on folder types_tool.manage_addTypeInformation(id='NewsFolder', add_meta_type="Factory-based Type Information", typeinfo_name="CMFPlone: Plone Folder") nf = getattr(types_tool, 'NewsFolder') nf.manage_changeProperties(filter_content_types=1, allowed_content_types=('News Item',)) actions=nf._cloneActions() for a in actions: if a.id == 'view': a.action = Expression('string:${object_url}/newsfolder_view') nf._actions=(actions) After a clone of the type is made based on Plone Folder, some changes are made: contents are filtered, and only News Items are allowed; also an action is changed to point to a custom template. This is a better option than using the copy/paste API like you might do in the ZMI. --jcc -- "Building Websites with Plone" http://plonebook.packtpub.com/ Enfold Systems, LLC http://www.enfoldsystems.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Factory-based Type Information
Hello, list. I have a problem with my product. I use Zope 2.7.5 and Plone 2.0.5. I need to create the copy of Document content-type on my product's install the same way as it is done in portal_types via "Factory-based Type Information" option of dropdown. I just need to have the copy of it and to alter some fields. Please advise. Thank you. -- Best regards, Denis Mishunoff mailto:[EMAIL PROTECTED] http://plonetarium.objectis.net ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )