[Zope-CMF] Re: Easiest way to make my own portal_type that is like CMFDocument but with extra properties

Tres Seaver tseaver@palladion.com
Mon, 20 Aug 2001 09:08:10 -0400


Lynn Walton wrote:

> 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?)


In your product, there is a "factory method" for your ZClass;  by
default, it would have the ID 'FU_CMFDocumentClass_add'.  You should
put that ID in the field.


>    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?)


You put the name of the skin method you want to show the user
immediately after creating the instance.  No inheritance is
involved.  The "stock" CMF would put 'metadata_edit_form' here.


>    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


This is a bug in the tool:  for now, you can work around the
problem by leaving "Visible?" unchecked when adding the action,
and then checking it and clicking save after adding it.  Here is
a patch for the problem, which I am about to check in:

Index: CMFCore/dtml/editActions.dtml
===================================================================
RCS file: /cvs-repository/Products/CMFCore/dtml/editActions.dtml,v
retrieving revision 1.3
diff -u -r1.3 editActions.dtml
--- CMFCore/dtml/editActions.dtml	6 Aug 2001 18:16:19 -0000	1.3
+++ CMFCore/dtml/editActions.dtml	20 Aug 2001 13:35:59 -0000
@@ -116,7 +116,8 @@
    <input type="hidden" name="visible_&dtml-index;:int:default"
           value="0" />
    <dtml-let chk="visible and 'checked' or ''">
-  <input type="checkbox" name="visible_&dtml-index;:boolean" &dtml-chk; />
+  <input type="checkbox" name="visible_&dtml-index;:boolean"
+         &dtml-chk; value="1" />
    </dtml-let>
    </div>
  </td>
@@ -235,7 +236,7 @@
    <div class="form-element">
    <input type="hidden" name="visible:int:default"
           value="0" />
-  <input type="checkbox" name="visible:boolean" checked />
+  <input type="checkbox" name="visible:boolean" checked value="1"/>
    </div>
  </td>
  </tr>



Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com