[Checkins] SVN: zc.sourcefactory/trunk/ Ported bugfix from 0.2.1
Christian Theune
ct at gocept.com
Sun Jun 10 08:46:59 EDT 2007
Log message for revision 76579:
Ported bugfix from 0.2.1
Changed:
U zc.sourcefactory/trunk/CHANGES.txt
U zc.sourcefactory/trunk/src/zc/sourcefactory/browser/README.txt
U zc.sourcefactory/trunk/src/zc/sourcefactory/browser/source.py
U zc.sourcefactory/trunk/src/zc/sourcefactory/policies.py
-=-
Modified: zc.sourcefactory/trunk/CHANGES.txt
===================================================================
--- zc.sourcefactory/trunk/CHANGES.txt 2007-06-10 12:44:25 UTC (rev 76578)
+++ zc.sourcefactory/trunk/CHANGES.txt 2007-06-10 12:46:58 UTC (rev 76579)
@@ -2,9 +2,15 @@
Changes
=======
-After 0.2
-=========
+After 0.2.1
+===========
+0.2.1 - 2007-07-10
+==================
+
+ - Fixed a bug in the contextual token policy that was handling the
+ resolution of values for a given token incorrectly.
+
0.2 - 2007-07-10
================
Modified: zc.sourcefactory/trunk/src/zc/sourcefactory/browser/README.txt
===================================================================
--- zc.sourcefactory/trunk/src/zc/sourcefactory/browser/README.txt 2007-06-10 12:44:25 UTC (rev 76578)
+++ zc.sourcefactory/trunk/src/zc/sourcefactory/browser/README.txt 2007-06-10 12:46:58 UTC (rev 76579)
@@ -155,6 +155,8 @@
... return context.keys()
... def getTitle(self, context, value):
... return context[value]
+ ... def getToken(self, context, value):
+ ... return 'token-%s' % value
>>> source = DemoContextualSource()(zip_to_city)
>>> sorted(list(source))
['06112', '06844']
@@ -176,7 +178,14 @@
<zc.sourcefactory.browser.source.FactoredTerm object at 0x...>
>>> terms.getTerm('06844').title
'Dessau'
+ >>> terms.getTerm('06844').token
+ 'token-06844'
+And in reverse we can get the value for a given token as well::
+
+ >>> terms.getValue('token-06844')
+ '06844'
+
Interfaces
==========
Modified: zc.sourcefactory/trunk/src/zc/sourcefactory/browser/source.py
===================================================================
--- zc.sourcefactory/trunk/src/zc/sourcefactory/browser/source.py 2007-06-10 12:44:25 UTC (rev 76578)
+++ zc.sourcefactory/trunk/src/zc/sourcefactory/browser/source.py 2007-06-10 12:46:58 UTC (rev 76579)
@@ -68,7 +68,11 @@
self.source.context, self.source, value, title, token,
self.request)
+ def getValue(self, token):
+ return self.source.factory.getValue(self.source.context, self.source,
+ token)
+
class FactoredTerm(object):
"""A title tokenized term."""
Modified: zc.sourcefactory/trunk/src/zc/sourcefactory/policies.py
===================================================================
--- zc.sourcefactory/trunk/src/zc/sourcefactory/policies.py 2007-06-10 12:44:25 UTC (rev 76578)
+++ zc.sourcefactory/trunk/src/zc/sourcefactory/policies.py 2007-06-10 12:46:58 UTC (rev 76579)
@@ -111,7 +111,10 @@
zope.interface.implements(zc.sourcefactory.interfaces.IContextualTokenPolicy)
def getValue(self, context, source, token):
- return super(BasicContextualTokenPolicy, self).getValue(source, token)
+ for value in source:
+ if source.factory.getToken(context, value) == token:
+ return value
+ raise KeyError, "No value with token '%s'" % token
def getToken(self, context, value):
return super(BasicContextualTokenPolicy, self).getToken(value)
More information about the Checkins
mailing list