<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.10.1">
</HEAD>
<BODY>
On Wed, 2006-06-14 at 09:59 +0200, Thierry FLORAC wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">On Tue, 2006-06-13 at 08:28 +0200, Philipp von Weitershausen wrote:</FONT>
<FONT COLOR="#000000">> As said above, 'result' will be security proxied. Security proxies for</FONT>
<FONT COLOR="#000000">> lists only allow methods that don't change the lists. result.sort()</FONT>
<FONT COLOR="#000000">> would change it. Hence it's forbidden.</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> An easy workaround is to use sorted():</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> result = IGalleryFolder(self.context).getImages()</FONT>
<FONT COLOR="#000000">> return sorted(result, cmp=...)</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> Note that using 'cmp' is very slow. It's much faster to use 'key':</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> result = IGalleryFolder(self.context).getImages()</FONT>
<FONT COLOR="#000000">> return sorted(result, key=lambda x: IGalleryPhoto(x).name)</FONT>
<FONT COLOR="#000000">Tried this, but it doesn't work because of another ForbiddenAttribute</FONT>
<FONT COLOR="#000000">error :</FONT>
<FONT COLOR="#000000"> File ".../gallery/browser/folder.py", line 39, in getImages</FONT>
<FONT COLOR="#000000"> return sorted(result, key=lambda x: IGalleryPhoto(x).name)</FONT>
<FONT COLOR="#000000"> File ".../gallery/browser/folder.py", line 39, in <lambda></FONT>
<FONT COLOR="#000000"> return sorted(result, key=lambda x: IGalleryPhoto(x).name)</FONT>
<FONT COLOR="#000000">ForbiddenAttribute: ('name', <gallery.photo.GalleryPhoto object at</FONT>
<FONT COLOR="#000000">0xa5bc46ac>)</FONT>
<FONT COLOR="#000000">As said before, 'IGalleryPhoto' (implemented by GalleryPhoto) is</FONT>
<FONT COLOR="#000000">provided in the "allowed_interface" attribute of my ZCML's view page</FONT>
<FONT COLOR="#000000">definition...</FONT>
</PRE>
</BLOCKQUOTE>
<BR>
Oops !!<BR>
Sorry, just did a mistake : I didn't notice for this last example that "name" attribute isn't defined into IGalleryPhoto interface.<BR>
Of course, it just works fine when using a IGalleryFolder attribute...<BR>
<BR>
Sorry again for the previous post !!<BR>
<BR>
Thierry<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
</TD>
</TR>
</TABLE>
</BODY>
<br />--
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.
</HTML>