[Zope-CMF] Problems with CMF 1.2/Zope 2.5.0 and a custom object that used to work fine :)

Doyon, Jean-Francois Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Sun, 27 Jan 2002 16:38:45 -0500


Hello,

I'm migrating to the latest CMF and Zope, and ran into a problem:

I have a custom defined content object type that I added in CMFDefault
called "Map" it simply holds one property, a number that i call MapID.

All was fine in 2.4.3, but now when I move to 2.5.0, I get the following
when trying to view the object:

Error Type: AttributeError
Error Value: __getitem__

Traceback (innermost last):
  File /usr/local/Zope-2.5.0/lib/python/ZPublisher/Publish.py, line 150, =
in
publish_module
  File /usr/local/Zope-2.5.0/lib/python/ZPublisher/Publish.py, line 114, =
in
publish
  File /usr/local/Zope-2.5.0/lib/python/Zope/__init__.py, line 158, in
zpublisher_exception_hook
    (Object: density)
  File /usr/local/Zope-2.5.0/lib/python/ZPublisher/Publish.py, line 98, i=
n
publish
  File /usr/local/Zope-2.5.0/lib/python/ZPublisher/mapply.py, line 88, in
mapply
    (Object: view)
  File /usr/local/Zope-2.5.0/lib/python/ZPublisher/Publish.py, line 39, i=
n
call_object
    (Object: view)
  File /usr/local/Zope-2.5.0/lib/python/Products/CMFCore/PortalContent.py=
,
line 173, in view
    (Object: density)
  File /usr/local/Zope-2.5.0/lib/python/Products/CMFCore/PortalContent.py=
,
line 160, in __call__
    (Object: density)
  File /usr/local/Zope-2.5.0/lib/python/Products/CMFCore/utils.py, line 1=
10,
in _getViewFor
    (Object: density)
  File /usr/local/Zope-2.5.0/lib/python/OFS/Traversable.py, line 163, in
restrictedTraverse
    (Object: density)
  File /usr/local/Zope-2.5.0/lib/python/OFS/Traversable.py, line 148, in
unrestrictedTraverse
    (Object: density)
AttributeError: (see above)


The object itself is fine, I can edit it and view it in the ZMI no proble=
m,
and I actually imported a bunch from a .zexp from the prvious Zope also
without incident.

Does any one know what's going on ? I looked at the archives, but the
problems refrred to in there don't seem to be the ones plaguing me here .=
..
i think :)

Here's the code in CMFDefault that handles the object, it is my first and
only custom made content type, so forgive me if you see anything horrible=
 in
there :)

ADD_CONTENT_PERMISSION =3D 'Add portal content'

import os, urllib
from Globals import DTMLFile, InitializeClass
from AccessControl import ClassSecurityInfo
from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.CMFCore import CMFCorePermissions
from utils import parseHeadersBody, SimpleHTMLParser, bodyfinder, _dtmldi=
r

factory_type_information =3D (
    {'id': 'Map',
     'meta_type': 'Map',
     'description': ('Map Object that contains a reference to the MapServ=
er
MapFile to use in the mapping tool.'),
     'product': 'CMFDefault',
     'icon': 'document_icon.gif',
     'factory': 'addMSMap',
     'immediate_view': 'map_edit_form',
     'actions': ({'name': 'View',
                  'action': 'map_preview',
                  'permissions': (CMFCorePermissions.View,)},
                 {'name': 'Edit',
                  'action': 'map_edit_form',
                  'permissions': (CMFCorePermissions.ModifyPortalContent,=
)},
                 { 'name': 'Metadata',
                   'action': 'metadata_edit_form',
                   'permissions': (CMFCorePermissions.ModifyPortalContent=
,)}
                 ),
     },
    )

def addMSMap(self, id, title=3D'', mapid=3D''):
    """Create an MSMap"""
    msmap_object =3D MSMap(id, title, mapid)
    self._setObject(id, msmap_object)

class MSMap(PortalContent, DefaultDublinCoreImpl):
    """MSMap Class"""

    meta_type=3D'Map'

    security =3D ClassSecurityInfo()

    def __init__(self, id, title=3D'', text=3D'', mapid=3D''):
        """Initialize an instance of the class"""
        DefaultDublinCoreImpl.__init__(self)
        self.id=3Did
        self.mapid=3Dmapid

=20
security.declareProtected(CMFCorePermissions.ModifyPortalContent,'manage_=
edi
t')

    manage_edit =3D DTMLFile('zmi_editMSMap', _dtmldir)

=20
security.declareProtected(CMFCorePermissions.ModifyPortalContent,'manage_=
edi
tMSMap' )

    def manage_editMSMap(self, mapid, REQUEST=3DNone):
        """ A ZMI (Zope Management Interface) level editing method """
        self._edit(mapid)
        if REQUEST is not None:
            REQUEST['RESPONSE'].redirect(
                self.absolute_url()
                + '/manage_edit'
                + '?manage_tabs_message=3DMap+updated'
                )
   =20
    def _edit(self, mapid):
        """Change the instance's properties """
        self.mapid =3D mapid

    security.declareProtected( CMFCorePermissions.ModifyPortalContent,
'edit' )

    edit =3D WorkflowAction(_edit)

    # For the search engine

    security.declareProtected(CMFCorePermissions.View, 'SearchableText')
       =20
    def SearchableText(self):
        """ Used by the catalog for basic full text indexing """
        return "%s" % (self.title)

   =20
InitializeClass(MSMap)

This object is basically the core of our business, so I kind of need it :=
)

Any help would be greatly appreciated, thanks!

Jean-Fran=E7ois Doyon
Internet Service Development and Systems Support
GeoAccess Division
Canadian Center for Remote Sensing
Natural Resources Canada
http://atlas.gc.ca
Phone: (613) 992-4902
Fax: (613) 947-2410