[Checkins] SVN: zope.annotation/trunk/ Merge changes made in the zope.annotation 3.4.1 to trunk.
Marius Gedminas
marius at pov.lt
Tue Aug 26 18:03:33 EDT 2008
Log message for revision 90369:
Merge changes made in the zope.annotation 3.4.1 to trunk.
Merge revisions 90364-90365 from 3.4 branch with
svn merge -r 90363:90365 svn+ssh://svn.zope.org/repos/main/zope.annotation/branches/3.4 .
Changed:
U zope.annotation/trunk/CHANGES.txt
U zope.annotation/trunk/buildout.cfg
U zope.annotation/trunk/setup.py
U zope.annotation/trunk/src/zope/annotation/README.txt
U zope.annotation/trunk/src/zope/annotation/factory.py
-=-
Modified: zope.annotation/trunk/CHANGES.txt
===================================================================
--- zope.annotation/trunk/CHANGES.txt 2008-08-26 22:01:00 UTC (rev 90368)
+++ zope.annotation/trunk/CHANGES.txt 2008-08-26 22:03:33 UTC (rev 90369)
@@ -2,8 +2,23 @@
Changes for zope.annotation
===========================
+==================
+3.5.0 (unreleased)
+==================
+...
+
+
==================
+3.4.1 (2008-08-26)
+==================
+
+- Annotation factories take care not to store proxies in the database, so
+ adapting an object wrapped in a LocationProxy works correctly.
+ Fixes https://bugs.launchpad.net/zope3/+bug/261620
+
+
+==================
3.4.0 (2007-08-29)
==================
Modified: zope.annotation/trunk/buildout.cfg
===================================================================
--- zope.annotation/trunk/buildout.cfg 2008-08-26 22:01:00 UTC (rev 90368)
+++ zope.annotation/trunk/buildout.cfg 2008-08-26 22:03:33 UTC (rev 90369)
@@ -6,3 +6,7 @@
[test]
recipe = zc.recipe.testrunner
eggs = zope.annotation [test]
+
+[ctags]
+recipe = z3c.recipe.tag:tags
+eggs = zope.annotation
Modified: zope.annotation/trunk/setup.py
===================================================================
--- zope.annotation/trunk/setup.py 2008-08-26 22:01:00 UTC (rev 90368)
+++ zope.annotation/trunk/setup.py 2008-08-26 22:03:33 UTC (rev 90369)
@@ -60,6 +60,7 @@
'zope.interface',
'zope.component',
'zope.location>=3.4.0b1.dev-r78903',
+ 'zope.proxy',
],
extras_require = dict(
test = ['zope.testing',
Modified: zope.annotation/trunk/src/zope/annotation/README.txt
===================================================================
--- zope.annotation/trunk/src/zope/annotation/README.txt 2008-08-26 22:01:00 UTC (rev 90368)
+++ zope.annotation/trunk/src/zope/annotation/README.txt 2008-08-26 22:03:33 UTC (rev 90369)
@@ -124,3 +124,46 @@
'my.unique.key'
>>> zope.location.interfaces.ILocation.providedBy(old_hoi)
True
+
+
+LocationProxies
+---------------
+
+Suppose your annotation proxy provides ILocation.
+
+ >>> class IPolloi(interface.Interface):
+ ... pass
+ >>> class Polloi(Persistent):
+ ... interface.implements(IPolloi, zope.location.interfaces.ILocation)
+ ... component.adapts(IFoo)
+ ... __name__ = __parent__ = 0
+ >>> component.provideAdapter(factory(Polloi, 'my.other.key'))
+
+Sometimes you're adapting an object wrapped in a LocationProxy.
+
+ >>> foo4 = Foo()
+ >>> import zope.location.location
+ >>> wrapped_foo4 = zope.location.location.LocationProxy(foo4, None, 'foo4')
+ >>> located_polloi = IPolloi(wrapped_foo4)
+
+At first glance it looks as if located_polloi is located under wrapped_foo4.
+
+ >>> located_polloi.__parent__ is wrapped_foo4
+ True
+ >>> located_polloi.__name__
+ 'my.other.key'
+
+but that's because we received a LocationProxy
+
+ >>> print type(located_polloi).__name__
+ LocationProxy
+
+If we unwrap located_polloi and look at it directly, we'll see it stores a
+reference to the real Foo object
+
+ >>> from zope.proxy import removeAllProxies
+ >>> removeAllProxies(located_polloi).__parent__ is foo4
+ True
+ >>> removeAllProxies(located_polloi).__name__
+ 'my.other.key'
+
Modified: zope.annotation/trunk/src/zope/annotation/factory.py
===================================================================
--- zope.annotation/trunk/src/zope/annotation/factory.py 2008-08-26 22:01:00 UTC (rev 90368)
+++ zope.annotation/trunk/src/zope/annotation/factory.py 2008-08-26 22:03:33 UTC (rev 90369)
@@ -18,6 +18,8 @@
import zope.component
import zope.interface
import zope.location.location
+import zope.location.interfaces
+import zope.proxy
import zope.annotation.interfaces
@@ -43,11 +45,14 @@
except KeyError:
result = factory()
annotations[key] = result
- # Location has to be set up late to allow location proxies
- # to be applied, if needed. This does not trigger an event and is idempotent
- # if location or containment is set up already.
- located_result = zope.location.location.located(result, context, key)
- return located_result
+ if zope.location.interfaces.ILocation.providedBy(result):
+ zope.location.location.locate(result,
+ zope.proxy.removeAllProxies(context), key)
+ if not (zope.location.interfaces.ILocation.providedBy(result)
+ and result.__parent__ is context
+ and result.__name__ == key):
+ result = zope.location.location.LocationProxy(result, context, key)
+ return result
# Convention to make adapter introspectable, used by apidoc
getAnnotation.factory = factory
More information about the Checkins
mailing list