<!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">&gt; As said above, 'result' will be security proxied. Security proxies for</FONT>
<FONT COLOR="#000000">&gt; lists only allow methods that don't change the lists. result.sort()</FONT>
<FONT COLOR="#000000">&gt; would change it. Hence it's forbidden.</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; An easy workaround is to use sorted():</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt;   result = IGalleryFolder(self.context).getImages()</FONT>
<FONT COLOR="#000000">&gt;   return sorted(result, cmp=...)</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; Note that using 'cmp' is very slow. It's much faster to use 'key':</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt;   result = IGalleryFolder(self.context).getImages()</FONT>
<FONT COLOR="#000000">&gt;   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 &quot;.../gallery/browser/folder.py&quot;, line 39, in getImages</FONT>
<FONT COLOR="#000000">    return sorted(result, key=lambda x: IGalleryPhoto(x).name)</FONT>
<FONT COLOR="#000000">  File &quot;.../gallery/browser/folder.py&quot;, line 39, in &lt;lambda&gt;</FONT>
<FONT COLOR="#000000">    return sorted(result, key=lambda x: IGalleryPhoto(x).name)</FONT>
<FONT COLOR="#000000">ForbiddenAttribute: ('name', &lt;gallery.photo.GalleryPhoto object at</FONT>
<FONT COLOR="#000000">0xa5bc46ac&gt;)</FONT>

<FONT COLOR="#000000">As said before, 'IGalleryPhoto' (implemented by GalleryPhoto) is</FONT>
<FONT COLOR="#000000">provided in the &quot;allowed_interface&quot; 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 &quot;name&quot; 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>