[Checkins] SVN: z3c.metrics/trunk/ * Fixed imports and tests to run with current Zope packages.

Michael Howitz mh at gocept.com
Thu Jul 22 02:56:11 EDT 2010


Log message for revision 114912:
  * Fixed imports and tests to run with current Zope packages.
  
  * Added extras_require `zope2` for Zope 2 requirements.
  
  

Changed:
  U   z3c.metrics/trunk/buildout.cfg
  U   z3c.metrics/trunk/docs/HISTORY.txt
  U   z3c.metrics/trunk/setup.py
  U   z3c.metrics/trunk/z3c/metrics/dispatch.py
  U   z3c.metrics/trunk/z3c/metrics/index.py
  U   z3c.metrics/trunk/z3c/metrics/index.txt
  U   z3c.metrics/trunk/z3c/metrics/meta.txt
  U   z3c.metrics/trunk/z3c/metrics/scale.txt
  U   z3c.metrics/trunk/z3c/metrics/testing.zcml
  U   z3c.metrics/trunk/z3c/metrics/zope2/index.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/tests.py

-=-
Modified: z3c.metrics/trunk/buildout.cfg
===================================================================
--- z3c.metrics/trunk/buildout.cfg	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/buildout.cfg	2010-07-22 06:56:10 UTC (rev 114912)
@@ -8,4 +8,4 @@
 
 [test-zope2]
 recipe = zc.recipe.testrunner
-eggs = z3c.metrics [test_zope2]
+eggs = z3c.metrics [zope2, test]

Modified: z3c.metrics/trunk/docs/HISTORY.txt
===================================================================
--- z3c.metrics/trunk/docs/HISTORY.txt	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/docs/HISTORY.txt	2010-07-22 06:56:10 UTC (rev 114912)
@@ -1,8 +1,16 @@
-Changelog
-=========
+===========
+ Changelog
+===========
 
-0.1 - 2009-04-08
-----------------
+0.2 (unreleased)
+================
 
-* Initial release
+* Fixed imports and tests to run with current Zope packages.
 
+* Added extras_require `zope2` for Zope 2 requirements.
+
+
+0.1 (2009-04-08)
+================
+
+* Initial release.
\ No newline at end of file

Modified: z3c.metrics/trunk/setup.py
===================================================================
--- z3c.metrics/trunk/setup.py	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/setup.py	2010-07-22 06:56:10 UTC (rev 114912)
@@ -7,6 +7,7 @@
       version=version,
       description="Index arbitrary values as scores for object metrics.",
       long_description=(
+          '.. contents::\n\n' +
           open(os.path.join("z3c", "metrics", "README.txt")).read() +
           "\n" + open(os.path.join("docs", "HISTORY.txt")).read()),
       # Get more strings from
@@ -15,7 +16,7 @@
         "Programming Language :: Python",
         "Topic :: Software Development :: Libraries :: Python Modules",
         ],
-      keywords='zope zop3 index',
+      keywords='zope zope3 index',
       author='Ross Patterson',
       author_email='me at rpatterson.net',
       url='http://pypi.python.org/pypi/z3c.metrics',
@@ -32,12 +33,15 @@
           'ZODB3',
           ],
       extras_require=dict(
+          zope2=[
+              'Zope2',
+              'Products.GenericSetup',
+              ],
           test=[
               'zope.testing',
               'zope.configuration',
-              ],
-          test_zope2=[
-              'Zope2',
+              'zope.app.component >= 3.9.0',
+              'zope.app.folder',
               ]),
 
       entry_points="""

Modified: z3c.metrics/trunk/z3c/metrics/dispatch.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/dispatch.py	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/dispatch.py	2010-07-22 06:56:10 UTC (rev 114912)
@@ -1,6 +1,6 @@
 from zope import interface, component
 from zope.app.component import hooks
-from zope.app.location import interfaces as location_ifaces
+from zope.location import interfaces as location_ifaces
 from zope.app.container import interfaces as container_ifaces
 from zope.app.security import interfaces as security_ifaces
 

Modified: z3c.metrics/trunk/z3c/metrics/index.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/index.py	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/index.py	2010-07-22 06:56:10 UTC (rev 114912)
@@ -3,7 +3,7 @@
 
 from zope import interface
 import zope.event
-from zope.app.event import objectevent
+import zope.component.interfaces
 
 from z3c.metrics import interfaces, scale
 
@@ -12,7 +12,7 @@
     pass
 
 
-class IndexesScoreEvent(objectevent.ObjectEvent):
+class IndexesScoreEvent(zope.component.interfaces.ObjectEvent):
     interface.implements(interfaces.IIndexesScoreEvent)
 
     def __init__(self, obj, indexes=()):

Modified: z3c.metrics/trunk/z3c/metrics/index.txt
===================================================================
--- z3c.metrics/trunk/z3c/metrics/index.txt	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/index.txt	2010-07-22 06:56:10 UTC (rev 114912)
@@ -84,13 +84,13 @@
 Infinity
 ========
 
-Pickle protocol 1 raises an error on infinite values.
+Pickle protocol 1 raises an error on infinite values. (No longer true
+for Python 2.5.)
 
     >>> import pickle
     >>> foo_index._scores[id(0)] = scale.inf
     >>> pickle.dumps(foo_index, 1)
-    Traceback (most recent call last):
-    SystemError: frexp() result out of range
+    'ccopy_reg...'
 
 As such, trying the change the score by a value that will result in
 the infinite float will raise an error.

Modified: z3c.metrics/trunk/z3c/metrics/meta.txt
===================================================================
--- z3c.metrics/trunk/z3c/metrics/meta.txt	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/meta.txt	2010-07-22 06:56:10 UTC (rev 114912)
@@ -43,7 +43,7 @@
     ...    i18n_domain="zope">
     ...   <include package="zope.app.component" file="meta.zcml" />
     ...   <include package="z3c.metrics" file="meta.zcml" />
-    ... 
+    ...
     ...   <utility
     ...      factory="z3c.metrics.testing.FooDocIndex"
     ...      provides="z3c.metrics.testing.IFooDocIndex" />
@@ -53,18 +53,18 @@
     ...   <utility
     ...      factory="z3c.metrics.testing.CreatorIndex"
     ...      provides="z3c.metrics.testing.ICreatorIndex" />
-    ... 
+    ...
     ...   <metrics:self
     ...      for="z3c.metrics.testing.IDocument"
     ...      interface="z3c.metrics.interfaces.ICreated"
     ...      field_name="created">
     ...     <metrics:weighted
-    ...        utility_interface="z3c.metrics.testing.IFooDocIndex" /> 
+    ...        utility_interface="z3c.metrics.testing.IFooDocIndex" />
     ...     <metrics:weighted
     ...        utility_interface="z3c.metrics.testing.IBarDocIndex"
     ...        weight="2" />
     ...   </metrics:self>
-    ... 
+    ...
     ...   <metrics:other
     ...      for="z3c.metrics.testing.IDocument
     ...           z3c.metrics.testing.IDescendant"
@@ -74,7 +74,7 @@
     ...     <metrics:weighted
     ...        utility_interface="z3c.metrics.testing.IBarDocIndex" />
     ...   </metrics:other>
-    ... 
+    ...
     ...   <metrics:other
     ...      for="zope.app.security.interfaces.IPrincipal
     ...           z3c.metrics.testing.IDocument"
@@ -84,7 +84,7 @@
     ...        utility_interface="z3c.metrics.testing.ICreatorIndex"
     ...        weight="2" />
     ...   </metrics:other>
-    ... 
+    ...
     ...   <metrics:other
     ...      for="zope.app.security.interfaces.IPrincipal
     ...           z3c.metrics.testing.IDescendant"
@@ -94,13 +94,13 @@
     ...     <metrics:weighted
     ...        utility_interface="z3c.metrics.testing.ICreatorIndex" />
     ...   </metrics:other>
-    ... 
+    ...
     ...   <metrics:init
     ...     for="zope.app.security.interfaces.IPrincipal">
     ...     <metrics:weighted
-    ...        utility_interface="z3c.metrics.testing.ICreatorIndex" /> 
+    ...        utility_interface="z3c.metrics.testing.ICreatorIndex" />
     ...   </metrics:init>
-    ... 
+    ...
     ... </configure>
     ... """)
 

Modified: z3c.metrics/trunk/z3c/metrics/scale.txt
===================================================================
--- z3c.metrics/trunk/z3c/metrics/scale.txt	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/scale.txt	2010-07-22 06:56:10 UTC (rev 114912)
@@ -87,15 +87,19 @@
 integer values.
 
     >>> import sys
-    >>> (datetime_scale.toValue(sys.maxint)-scale.epoch
+    >>> result = (datetime_scale.toValue(sys.maxint)-scale.epoch
     ...  ).days/365
-    7
+    >>> if sys.maxint > 2147483647:
+    ...    result == 16 # 64-Bit system
+    ... else:
+    ...    result == 7 # 32-Bit system
+    True
 
 We can calculate the maximum ratio we can use if we project some
 maximums for the application:
 
   - maximum total count of dates across all metrics for an object
-    
+
     If we assume one metric may record the dates of all posts in a
     forum, then the maximum for that one metric might be 100,000
     posts.  Assuming the rest of the metrics record an insignificant
@@ -103,7 +107,7 @@
     our maximum here.
 
     >>> count_max = 100000
- 
+
   - maximum average metric weight across all the metrics
 
     If we assume that we have a maximum metric that we need to be 1000
@@ -168,7 +172,7 @@
     >>> _ = IIBTree.IIBTree({0: int(
     ...      max_datetime_num*count_max*weight_max_avg)})
     Traceback (most recent call last):
-    TypeError: expected integer value
+    OverflowError: 10240000000
 
 Furthermore, in the cases above the absense of a minimum guaranteed
 granularity means that dates close to the beginning date will have the

Modified: z3c.metrics/trunk/z3c/metrics/testing.zcml
===================================================================
--- z3c.metrics/trunk/z3c/metrics/testing.zcml	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/testing.zcml	2010-07-22 06:56:10 UTC (rev 114912)
@@ -5,13 +5,13 @@
   <include package="zope.app.component" file="meta.zcml" />
 
   <adapter
-      for="zope.interface.Interface" 
-      provides="zope.component.interfaces.ISiteManager"
+      for="zope.interface.Interface"
+      provides="zope.component.interfaces.IComponentLookup"
       factory="zope.app.component.site.SiteManagerAdapter"
       />
 
   <adapter
-      provides="zope.app.location.interfaces.ISublocations"
+      provides="zope.location.interfaces.ISublocations"
       for="zope.app.container.interfaces.IReadContainer"
       factory="zope.app.container.contained.ContainerSublocations"
       />

Modified: z3c.metrics/trunk/z3c/metrics/zope2/index.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/index.py	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/zope2/index.py	2010-07-22 06:56:10 UTC (rev 114912)
@@ -6,7 +6,6 @@
 from OFS import SimpleItem
 from Products.ZCatalog import interfaces as zcatalog_ifaces
 from Products.PluginIndexes import interfaces as plugidx_ifaces
-from Products.PluginIndexes.TextIndex import Vocabulary
 from Products.GenericSetup import interfaces as gs_ifaces
 from Products.GenericSetup.PluginIndexes import exportimport
 
@@ -39,6 +38,9 @@
     """sro"""
 
 
+class _extra: pass
+
+
 class MetricsIndex(index.Index, SimpleItem.SimpleItem):
     """A Metrics Index in a ZCatalog"""
     interface.implements(IMetricsIndex)
@@ -48,7 +50,7 @@
         self.__catalog_path = caller.getPhysicalPath()
 
         if extra is None:
-            extra = Vocabulary._extra()
+            extra = _extra()
 
         # TODO: the utility registration should be moved to an INode
         # GS handler to be run after the index is added

Modified: z3c.metrics/trunk/z3c/metrics/zope2/tests.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/tests.py	2010-07-22 06:29:09 UTC (rev 114911)
+++ z3c.metrics/trunk/z3c/metrics/zope2/tests.py	2010-07-22 06:56:10 UTC (rev 114912)
@@ -1,7 +1,12 @@
 import unittest
 from zope.testing import doctest, cleanup
 
-from Testing import ZopeTestCase
+try:
+    from Testing import ZopeTestCase
+except ImportError:
+    have_zope2 = False
+else:
+    have_zope2 = True
 
 from zope.configuration import xmlconfig
 
@@ -17,15 +22,16 @@
     cleanup.tearDown()
 
 
-def test_suite():
-    return ZopeTestCase.ZopeDocFileSuite(
-        'catalog.txt',
-        setUp=setUp, tearDown=tearDown,
-        optionflags=(
-            doctest.REPORT_NDIFF |
-            #doctest.REPORT_ONLY_FIRST_FAILURE |
-            doctest.NORMALIZE_WHITESPACE |
-            doctest.ELLIPSIS))
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+if have_zope2:
+    def test_suite():
+        return ZopeTestCase.ZopeDocFileSuite(
+            'catalog.txt',
+            setUp=setUp, tearDown=tearDown,
+            optionflags=(
+                doctest.REPORT_NDIFF |
+                #doctest.REPORT_ONLY_FIRST_FAILURE |
+                doctest.NORMALIZE_WHITESPACE |
+                doctest.ELLIPSIS))
+else:
+    def test_suite():
+        return unittest.TestSuite()



More information about the checkins mailing list