Re: [Zope3-Users] Question about "ForbiddenAttribute"...

2006-06-14 Thread Thierry FLORAC
On Tue, 2006-06-13 at 08:26 +0200, Marco Mariani wrote:
> Thierry FLORAC wrote:
> >> name="images.html"
> > for=".interfaces.IGalleryFolder"
> > allowed_interface=".interfaces.IGalleryPhoto"
> > template="folder_images.pt"
> > permission="zope.View"
> > class=".folder.FolderInfo"
> > menu="zmi_views" title="Images" />
> >
> > But when trying to display the view, a ForbiddenAttribute exception is
> > raised :
> >   File ".../browser/folder.py", line 39, in getImages
> > result.sort (lambda x,y:
> >  cmp(IGalleryPhoto(x).name,IGalleryPhoto(y).name))
> >   ForbiddenAttribute:('sort',[,...] 
> >
> > So the forbidden attribute seems to be the "sort" method of the
> > resulting array, which of course isn't part of any of my interfaces.
> >
> > In such a case, I solved the problem by moving the "getSortedImages" to
> > the folder interface and content class.
> >   
> You have to define an empty getImages method on the interface.

"getImages()" is already defined into IPhotoFolder interface. But Philip
already sent a reply with a full and clear explanation of my problem...


> > But that may not always be possible, so how can I get access to such
> > methods ??
> >   
> Why should it not be possible? After all, you defined the FolderInfo
> view for the IGalleryFolder _Interface_, not the GalleryFolder class.

What I just mean (but perhaps I'm wrong) is that in my use case, the
"getSortedImages()" method is only used for presentation purpose in a
specific context, a specific browser view.
I think this kind of method shouldn't have to be defined in an interface
which main goal is to define generic content handling methods...
I don't know if my explanation is clear :-(

  Thierry




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

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Question about "ForbiddenAttribute"...

2006-06-12 Thread Marco Mariani
Thierry FLORAC wrote:
>name="images.html"
> for=".interfaces.IGalleryFolder"
> allowed_interface=".interfaces.IGalleryPhoto"
> template="folder_images.pt"
> permission="zope.View"
> class=".folder.FolderInfo"
> menu="zmi_views" title="Images" />
>
> But when trying to display the view, a ForbiddenAttribute exception is
> raised :
>   File ".../browser/folder.py", line 39, in getImages
> result.sort (lambda x,y:
>  cmp(IGalleryPhoto(x).name,IGalleryPhoto(y).name))
>   ForbiddenAttribute:('sort',[,...] 
>
> So the forbidden attribute seems to be the "sort" method of the
> resulting array, which of course isn't part of any of my interfaces.
>
> In such a case, I solved the problem by moving the "getSortedImages" to
> the folder interface and content class.
>   
You have to define an empty getImages method on the interface.
> But that may not always be possible, so how can I get access to such
> methods ??
>   
Why should it not be possible? After all, you defined the FolderInfo
view for the IGalleryFolder _Interface_, not the GalleryFolder class.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Question about "ForbiddenAttribute"...

2006-06-12 Thread Thierry FLORAC
Hi,

I'm trying to build a sample photos management application for Zope-3.2,
with the following interfaces and classes :

 - class IGalleryPhoto(IContainer)
 ...

 - class IGalleryContainer(IContainer)
 (marker interface used for preconditions)

 - class IGalleryFolder(IGalleryContainer)
 def getImages():
   ...

 - class IGallery(IGalleryFolder,IPossibleSite)
 ...

 - class GalleryPhoto(BTreeContainer)
 ...

 - class GalleryFolder(Folder)
 def getImages(self):
   return [item for item in self.values() 
 if IGalleryPhoto.providedBy(item)]

 - class Gallery(GalleryFolder, SiteManagerContainer)
 ...

Until now, it's OK !
After that, I created a sample view based on a page template for
IGalleryFolder, using a view class :

  -  ... 

  - class FolderInfo:

  def getImages(self):
"""Get a sorted list of images"""
result = IGalleryFolder(self.context).getImages()
result.sort (lambda x,y: cmp(IGalleryPhoto(x).name,
 IGalleryPhoto(y).name))
return result

The view is registered in ZCML like this :

  

But when trying to display the view, a ForbiddenAttribute exception is
raised :
  File ".../browser/folder.py", line 39, in getImages
result.sort (lambda x,y:
 cmp(IGalleryPhoto(x).name,IGalleryPhoto(y).name))
  ForbiddenAttribute:('sort',[,...] 

So the forbidden attribute seems to be the "sort" method of the
resulting array, which of course isn't part of any of my interfaces.

In such a case, I solved the problem by moving the "getSortedImages" to
the folder interface and content class.
But that may not always be possible, so how can I get access to such
methods ??

Thanks for any help,
Thierry



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

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users