[Zope-CMF] Re: Easiest way to make my own portal_type that is like
CMFDocument but with extra properties
Lynn Walton
waltonl@franklin.edu
Mon, 20 Aug 2001 00:07:18 -0500
Tres Seaver wrote:
> If you want to create your own type which has everything
> CMFDefault.Document does, but adds an additional three properties,
> the simplest tack would be:
>
> 1. Create a ZClass, derived from CMFDefault.Document.
Where did you create this?
> 2. Add a propertysheet to the ZClass with the properties you need.
>
> 3. Customize the skins in your portal to use / update these properties.
Would this make me unable to use the plain CMFDocument if my skins are changed to
use these properties ?
Or are you talking about a skin that is only applied to my new type? Can you give
me an example of a skin you changed, what it's effect is, etc?
Here is actually what I decided to try even though it seemed a little longer than
what Tres suggested: But something's not allowing me to define actions for the
portal_type. Can anyone see why?
What I did: (which is very much like following the PortalPoll Tutorial)
Went to Control_Panel/Products
Selected Add Product
Gave name FU_CMFDocument
Selected FU_CMFDocument from Products List
Select 'ZClass' from Add List
Entered
Name: FU_CMFDocumentClass
Title: FU_CMFDocumentClass
Metatype: FU_CMFDocument
Left checkboxes checked for both:
creating constructors and
including standard Zope persistent object base classes
In Add to Base Classes, Only chose CMFDefault: Document
Hit Add button.
Select Properties Tab of the FU_CMFDocumentClass ZClass
Added 3 properties, all strings with no default value:
topMenuExpand
secondMenuExpand
highlightMenuItem
Select Define Permissions tab of the FU_CMFDocumentClass ZClass
Change the permission for Create class instance to Add portal Content
Select my wwwPortal, then portal_types, then the Contents tab.
Select Factory-based Type Information from Add list
Enter an id: I used FU_Document and left None for default type information.
Click on the new content type FU_Document to modify it's properties
Title FU Document
Description: Left blank
Meta type: FU_CMFDocument (must be same as metatype defined for
the zclass)
Icon: Left blank
Product name: FU_CMFDocument (must be same as product name where
zclass resides)
Factory method left blank ... not sure if it will inherit from
CMFDocument (later I also tried putting in addDocument here which is what
CMFDocument has, and I figured if I don't have one defined, it will inherit
CMFDocument's. Is that a wrong assumption?)
Initial view name left blank ... not sure if it will inherit from
CMFDocument (later I also tried putting in metadata_edit_form here which is what
CMFDocument has, and I figured if I don't have one defined, it will inherit
CMFDocument's. Is that a wrong assumption?)
Filter content types?
Allowed content types
Allow Discussion?
Wasn't sure if needed to define actions since it might inherit from CMFDocument,
so I didn't.
But when I go to my portal and choose New to add content, my FU Document doesn't
appear as a choice.
So I went to try to define Actions and started by entering:
Name View
Id view
Action document_view
Permission View
Category object
Visible? checked
But when I hit Add I got:
Zope Error
Zope has encountered an error while publishing this resource.
Error Type: ValueError
Error Value: invalid literal for int(): on
Traceback (innermost last):
File
/opt/WWW/ZopeInstallation/Zope_software_home/lib/python/ZPublisher/Publish.py,
line 223, in publish_module
File
/opt/WWW/ZopeInstallation/Zope_software_home/lib/python/ZPublisher/Publish.py,
line 187, in publish
File /opt/WWW/ZopeInstallation/Zope_software_home/lib/python/Zope/__init__.py,
line 226, in zpublisher_exception_hook
(Object: ElementWithAttributes)
File
/opt/WWW/ZopeInstallation/Zope_software_home/lib/python/ZPublisher/Publish.py,
line 171, in publish
File
/opt/WWW/ZopeInstallation/Zope_software_home/lib/python/ZPublisher/mapply.py, line
160, in mapply
(Object: addAction)
File
/opt/WWW/ZopeInstallation/Zope_software_home/lib/python/ZPublisher/Publish.py,
line 112, in call_object
(Object: addAction)
File /opt/WWW/ZopeInstallation/InstanceHome/Products/CMFCore/TypesTool.py, line
321, in addAction
(Object: ElementWithAttributes)
ValueError: (see above)
So that's where I've left it.
Thanks,
Lynn