[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zope-cmf
Subject:    RE: [Zope-CMF] Problems with CMF 1.2/Zope 2.5.0 and a custom obje
From:       "Doyon, Jean-Francois" <Jean-Francois.Doyon () CCRS ! NRCan ! gc ! ca>
Date:       2002-01-28 14:45:02
[Download RAW message or body]

Never mind, I figured it out :)

J.F.

-----Original Message-----
From: Doyon, Jean-Francois [mailto:Jean-Francois.Doyon@CCRS.NRCan.gc.ca]
Sent: Sunday, January 27, 2002 4:39 PM
To: 'zope-cmf@zope.org'
Subject: [Zope-CMF] Problems with CMF 1.2/Zope 2.5.0 and a custom object
that used to work fine :)


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, in
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, in
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 110,
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 problem,
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 = '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, _dtmldir

factory_type_information = (
    {'id': 'Map',
     'meta_type': 'Map',
     'description': ('Map Object that contains a reference to the MapServer
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='', mapid=''):
    """Create an MSMap"""
    msmap_object = MSMap(id, title, mapid)
    self._setObject(id, msmap_object)

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

    meta_type='Map'

    security = ClassSecurityInfo()

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

 
security.declareProtected(CMFCorePermissions.ModifyPortalContent,'manage_edi
t')

    manage_edit = DTMLFile('zmi_editMSMap', _dtmldir)

 
security.declareProtected(CMFCorePermissions.ModifyPortalContent,'manage_edi
tMSMap' )

    def manage_editMSMap(self, mapid, REQUEST=None):
        """ 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=Map+updated'
                )
    
    def _edit(self, mapid):
        """Change the instance's properties """
        self.mapid = mapid

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

    edit = WorkflowAction(_edit)

    # For the search engine

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

    
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çois 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


_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic