[Zope3-Users] Re: Question about "ForbiddenAttribute"...
Thierry FLORAC
tflorac at ulthar.net
Wed Jun 14 03:59:04 EDT 2006
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...
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