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

Thierry FLORAC tflorac at ulthar.net
Wed Jun 14 04:15:19 EDT 2006


On Wed, 2006-06-14 at 09:59 +0200, Thierry FLORAC wrote:

> On Tue, 2006-06-13 at 08:28 +0200, Philipp von Weitershausen wrote:
> > As said above, 'result' will be security proxied. Security proxies for
> > lists only allow methods that don't change the lists. result.sort()
> > would change it. Hence it's forbidden.
> > 
> > An easy workaround is to use sorted():
> > 
> >   result = IGalleryFolder(self.context).getImages()
> >   return sorted(result, cmp=...)
> > 
> > Note that using 'cmp' is very slow. It's much faster to use 'key':
> > 
> >   result = IGalleryFolder(self.context).getImages()
> >   return sorted(result, key=lambda x: IGalleryPhoto(x).name)
> 
> Tried this, but it doesn't work because of another ForbiddenAttribute
> error :
> 
>   File ".../gallery/browser/folder.py", line 39, in getImages
>     return sorted(result, key=lambda x: IGalleryPhoto(x).name)
>   File ".../gallery/browser/folder.py", line 39, in <lambda>
>     return sorted(result, key=lambda x: IGalleryPhoto(x).name)
> ForbiddenAttribute: ('name', <gallery.photo.GalleryPhoto object at
> 0xa5bc46ac>)
> 
> As said before, 'IGalleryPhoto' (implemented by GalleryPhoto) is
> provided in the "allowed_interface" attribute of my ZCML's view page
> definition...


Oops !!
Sorry, just did a mistake : I didn't notice for this last example that
"name" attribute isn't defined into IGalleryPhoto interface.
Of course, it just works fine when using a IGalleryFolder attribute...

Sorry again for the previous post !!

Thierry



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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20060614/afdfeda1/attachment.htm


More information about the Zope3-users mailing list