Hi Folks
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
for anyone else who wants to use zope.deferredimport under google app
engine.  (With some content models
zope.deferredimport is a great way of dealing with cyclic dependancies and
possibly improving startup times - see bottom of this email.)

Below is a minimal set of changes to zope.proxy.__init__  that is required
so that zope.deferredimport can be used.
It does mean you need peak.utils to implement a basic proxy.

try:

    from zope.proxy._zope_proxy_proxy import *
    from zope.proxy._zope_proxy_proxy import _CAPI

except NotImplementedError:

    from peak.util.proxies import ObjectProxy

    class ProxyBase(ObjectProxy):
         pass

    def getProxiedObject(obj):

         if hasattr(obj,'__subject__'):
             return obj.__subject__
         else:
             return obj

    def removeAllProxies(obj):
        return getProxiedObject(obj)


    def sameProxiedObjects(obj1,obj2):
        if getProxiedObject(obj1) == getProxiedObject(obj2):
            return True
        else:
            return False

There are a couple of other zope.proxy functions from the 'c' api that I
haven't looked at yet as they aren't used by zope.deferredimport.
Suggestions on improving it and/or followups on the other functions would
also be welcome.  I have also found that deferred import can help
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
which can allow you to stagger you startup costs. (For instance edit
functionality of a site could be deferred until someone
actually edits something).

Hope this helps someone

Regards

Tim Hoffman
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to