[Zope-dev] For the record - a minimum changes to zope.proxy to support zope.deferredimport under google app engine
Tim Hoffman
timh at zute.net
Wed Aug 12 23:30:18 EDT 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope-dev/attachments/20090813/bf43d48b/attachment.html
More information about the Zope-Dev
mailing list