[Zope] PropertySheets in python products

Richard Jennings rjennings at stradefi.com
Fri Sep 12 13:17:08 EDT 2003


I am trying to create a product which supports multiple propertysheets and is
accessible using the standard ZMI.  Following the mxm Easy product (thanks to mxm!) 
and advice received on this site, I have arrived at the code listed below. This
installs a product in its containing folder and when I view the item, I get the page
rendered from OFS/dtml/propertysheets.dtml.  Spartan, to say the least!
I get a reference to webdav (to be expected) and an Add button. Clicking the button
returns the error:
 
Error Type: AttributeError
Error Value: manage_addPropertySheetForm

which is the name of the input control.  There is no such method in propertysheets.py.

My questions:

1. When I look at the dtml for OFS/dtml/propertysheets.dtml, I have the feeling I'm
looking at unfinished business - am I?

2. I expect to see a form listing existing property sheets with controls for adding
new ones - does this already exist, if so where?

3. I am I going about this in the right way or have I misunderstood completely?

When I have finished, I intend to contibute component 'rpjCompoundItem' as a
complement to mxm's mxmSimpleItem - it might help newbies like myself. 

TIA

Richard Jennings

---------------------------------------------
from OFS import SimpleItem
from OFS.PropertySheets import PropertySheets
from Products.ZCatalog.CatalogPathAwareness import CatalogAware
from Globals import DTMLFile
from DateTime import DateTime


class ssCompoundItem(CatalogAware, PropertySheets, SimpleItem.SimpleItem):

    """A base class for creating compound components"""

    meta_type = 'ssCompoundItem'

    manage_options = (
    {'label':'propertysheets', 'action': 'manage'},
    )+ SimpleItem.SimpleItem.manage_options

    __ac_permissions__= SimpleItem.SimpleItem.__ac_permissions__ + \
    (
        ('Manage properties', ('manage_addPropertySheet',
                               'addPropertySheet',
                               'delPropertySheet'
                               )),
        ('Access contents information',
         ('items', 'values', 'get', ''),
         ('Anonymous', 'Manager'),
         ),
        ('View management screens', ('manage',)),
        )

    def __init__(self, id):
        "Inits the product with default values"
        self.id = id

manage_addForm = DTMLFile('dtml/manage_addForm', globals())

#
# constructor methods for adding component to folder.
#

def manage_addAction(self, id=None, REQUEST=None):
    "Add ssCompoundItem to ObjectManager"
    return addClass(self, id, ssCompoundItem, REQUEST)

def addClass(self, id=None, theClass=None, REQUEST=None):
    "Add an arbitrary class to a folder to a folder."
    # if no id passed, generate one from the datetime
    if id == None:
        id = DateTime().strftime('%Y%m%d_%H%M%S')
    self._setObject(id, theClass(id))
    if REQUEST is not None:
        getattr(self, id).manage_changeProperties(REQUEST)
        return self.manage_main(self, REQUEST)

constructors = (manage_addForm, manage_addAction)





More information about the Zope mailing list