I am a !#4@head ;-)<div><br></div><div>Forgot the else: clause in the code I posted. Corrected code is below.</div><div><br></div><div>T <br><br><div class="gmail_quote">On Thu, Aug 13, 2009 at 11:30 AM, Tim Hoffman <span dir="ltr">&lt;<a href="mailto:timh@zute.net">timh@zute.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Folks<div><br></div><div>This is a quick and dirty change and to be honest the main reason I am posting it here is so there is a searchable record</div>
<div>for anyone else who wants to use zope.deferredimport under google app engine.  (With some content models</div>
<div>zope.deferredimport is a great way of dealing with cyclic dependancies and possibly improving startup times - see bottom of this email.)</div><div><br></div><div>Below is a minimal set of changes to zope.proxy.__init__  that is required so that zope.deferredimport can be used.</div>

<div>It does mean you need peak.utils to implement a basic proxy.</div><div><br></div><div></div></blockquote><div><br></div><div><br></div><div>incorrect code shown,</div><div><br></div><div>Should have read</div><div><br>
</div><div><span class="Apple-style-span" style="border-collapse: collapse; "><div>try:</div><div><br></div><div>    from zope.proxy._zope_proxy_proxy import *</div><div>    from zope.proxy._zope_proxy_proxy import _CAPI</div>
<div><br></div><div>except NotImplementedError:</div><div>    pass</div><div><br></div><div>else:</div><div><br></div><div>    from peak.util.proxies import ObjectProxy</div><div>     </div><div>    class ProxyBase(ObjectProxy):</div>
<div>         pass</div><div>     </div><div>    def getProxiedObject(obj):</div><div>         </div><div>         if hasattr(obj,&#39;__subject__&#39;):</div><div>             return obj.__subject__</div><div>         else:</div>
<div>             return obj</div><div><br></div><div>    def removeAllProxies(obj):</div><div>        return getProxiedObject(obj)</div><div><br></div><div><br></div><div>    def sameProxiedObjects(obj1,obj2):</div><div>
        if getProxiedObject(obj1) == getProxiedObject(obj2):</div><div>            return True</div><div>        else:</div><div>            return False     </div></span></div><div><br></div><div><br></div><div><br></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><br></div><div>There are a couple of other zope.proxy functions from the &#39;c&#39; api that I haven&#39;t looked at yet as they aren&#39;t used by zope.deferredimport.</div>

<div>Suggestions on improving it and/or followups on the other functions would also be welcome.  I have also found that deferred import can help</div><div>with app engine startup times as it means you can import a module you depend on but not really import the code until it gets touched</div>

<div>which can allow you to stagger you startup costs. (For instance edit functionality of a site could be deferred until someone</div><div>actually edits something).</div><div><br></div><div>Hope this helps someone </div>

<div><br></div><div>Regards</div><div><br></div><font color="#888888"><div>Tim Hoffman</div>
</font></blockquote></div><br></div>