[Zope] Zwiki extension work - stuck changing new properties

Geoff Gardiner ggardiner@synomics.com
Wed, 17 May 2000 17:15:29 +0100


Sorry for a slightly lengthy post - hope this is the right list.

I'm trying to extend Zwiki functionality, and have got quite a long way with
what I want - basically restricting some users to append-only in certain
circumstances.

However, although I can create the new properties, I'm not able to access
them in the edit method and I don't see what I should be doing. Other
properties seem to be accessible, but not my new ones (although they are
visible in the properties tab, and can be read Ok). I have tried appending
'self.' but this just comes up with an error telling me that they don't
exist.

The fragments below are all that I have added to the Zwiki product (see the
geoffg comments below for what I've done), but I've got some additions to
zwiki.zexp as well to provide forms input.

Thank you again for any and all help,
Geoff Gardiner


In ZwikiPage.py ....


class ZWikiPage(DTMLDocument): #, CatalogAware):
    """A ZWikiPage is a DTML Document which knows how to render itself in
       various wiki styles, and provides some utility methods to support
       wiki-building.
    """
    meta_type="ZWiki Page"
    icon     ="misc_/ZWiki/ZWikiPage_icon"
    page_type=DEFAULT_PAGE_TYPE

    # how would you append to the superclass' _properties here ??  #'
    _properties=({'id':'title', 'type': 'string', 'mode':'w'},
                 {'id':'page_type', 'type': 'string', 'mode': 'w'},
                 # ken's parenting code:
                 {'id':'parents', 'type': 'lines', 'mode': 'w'},
                 # ^^^ ken's parenting code
                 # VVV --- geoffg's managed_mode code --- Tested
                 {'id':'managed_mode', 'type': 'boolean', 'mode': 'w'},
                 {'id':'page_owner', 'type': 'string', 'mode': 'w'}
                 # ^^^ end geoffg's managed_mode code ---
                 )

    __ac_permissions__=(
        # 'manage_edit','manage_upload' already part of Change DTML Doc
permission - ok here ??
        ('Change ZWiki Pages',
('edit','PUT','manage_edit','manage_upload')),
        # VVV --- geoffg's managed_mode code --- Tested
        ('Manage ZWiki Pages',
('edit','PUT','manage_edit','manage_upload')),
        # ^^^ end geoffg's managed_mode code ---
        # add a View permission here ??
        # useful to define default roles ??
        )

    # ken's parenting code:
    parents = None
    # ^^^ ken's parenting code
    # VVV --- geoffg's managed_mode code --- Tested
    managed_mode = 0
    page_owner = ''
    # ^^^ end geoffg's managed_mode code ---
....


    def edit(self, text=None, REQUEST=None, submit=None, type=None,
             timeStamp=None):
        """change a ZWikiPage's content and/or markup type
        """
        self._validateProxy(REQUEST)    # correct ??

        self.checkEditTimeStamp(timeStamp)

        if type is not None:
            self.page_type = type

        # VVV --- geoffg's managed_mode additions ---
        # Testing - logic Ok but can't access properties - why not?
        # edit form has hidden fields:
        #   'check_managed_mode' - look for existence of 'new_managed_mode'
checkbox
        #   'check_page_owner' - look for existence of 'clear_page_owner'
checkbox
        if REQUEST is not None:
          if REQUEST.has_key('check_managed_mode'):
            if REQUEST.has_key('new_managed_mode'):
              managed_mode=1
            else:
              managed_mode=0
          if managed_mode:
            if REQUEST.has_key('check_page_owner'):
              if REQUEST.has_key('clear_page_owner'):
                page_owner=''
              else:
                page_owner=REQUEST['AUTHENTICATED_USER']
          else:
            page_owner=''
        # ^^^ end geoffg's managed_mode additions

        if text is not None:
....