[Zope3-Users] ForbiddenAttribute on "locate" method

Thierry FLORAC tflorac at ulthar.net
Tue Oct 10 18:52:28 EDT 2006


  Hi,

I try to setup a little application but have a probably little problem
with a ForbiddenAttribute exception on "location.locate" method.
Here is my setup :

        class IPhoto(IContainer,IContained):
            """Photo handling interface"""
            ...
            image = Bytes(...)
            ...
        
        class Photo(Folder):
            """Photo handling class"""
            ...
            image = None
            def __init__(self, image=None):
                super(Photo,self).__init__()
                self.__parent__ = self.__name__ = None
                if image:
                    self.image = image
            ...
        
        class IEvent(IContained):
            """Event handling interface"""
            ...
        
        class Event(Persistent):
            """Event handling class"""
            ...
            def __init__(self):
                super(Event,self).__init__()
                self.__parent__ = self.__name__ = None

In my event creation form (derived from formlib.AddForm), I put
something like this, without a problem :

        def create(self, data):
            event = Event()
            if data.has_key('image'):
                event.image = Photo(image=data['image'])
                location.locate(event.image, event, 'image')
            form.applyChanges(event, self.form_fields, data)
            return event

"event.image" access can then be granted easily in an URL through a
"z3c.traverser" plug-in and everything works fine... until now !
Because when I'm trying to make the same thing in an edit form to update
an existing event, an exception is raised :

        def edit(self, action, data):
            changed = False
            event = self.context
            if data.has_key('image'):
                event.image = Photo(image=data['image'])
                location.locate(event.image, event, 'image')
                changed = True
            return super(EventEditForm,self).edit(action, data) or
        changed

Here is the traceback :

Traceback (most recent call last):
  File "/usr/local/zope/3.3.0/lib/python/zope/publisher/publish.py", line 133, in publish
        result = publication.callObject(request, obj)
  File "/usr/local/zope/3.3.0/lib/python/zope/app/publication/zopepublication.py", line 161, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  File "/usr/local/zope/3.3.0/lib/python/zope/publisher/publish.py", line 108, in mapply
    return debug_call(obj, args)
   - __traceback_info__: <security proxied zope.app.publisher.browser.viewmeta.NewsEventEditForm instance at 0xa677e20c>
  File "/usr/local/zope/3.3.0/lib/python/zope/publisher/publish.py", line 114, in debug_call
    return obj(*args)
  File "/usr/local/zope/3.3/lib/python/zope/formlib/form.py", line 751, in __call__
    self.update()
  File "/usr/local/zope/3.3/lib/python/zope/formlib/form.py", line 732, in update
    result = action.success(data)
  File "/usr/local/zope/3.3/lib/python/zope/formlib/form.py", line 582, in success
    return self.success_handler(self.form, self, data)
  File "/var/local/zope/3.3/lib/python/ulthar/forms/forms.py", line 104, in handle_edit_action
    self.edit_action(action,data)
  File "/var/local/zope/3.3/lib/python/ulthar/forms/forms.py", line 107, in edit_action
    if not self.edit(action, data):
  File "/var/local/zope/3.3/lib/python/usf/news/browser/event.py", line 85, in edit
    location.locate(event.image, event, 'image')
  File "/usr/local/zope/3.3.0/lib/python/zope/location/location.py", line 71, in locate
    object.__parent__ = parent
ForbiddenAttribute: ('__parent__', <gallery.photo.Photo object at 0xa678f62c>)


I've tried to setup different permissions and access rights, but without success.
So any help would be great !

Thanks,
Thierry



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Zope3-users mailing list