[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/annotation/ No need for an underscored module. Also, provide standard Python header.

Philipp von Weitershausen philikon at philikon.de
Thu Apr 6 15:04:55 EDT 2006


Log message for revision 66606:
  No need for an underscored module. Also, provide standard Python header.
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/annotation/__init__.py
  D   Zope3/branches/jim-adapter/src/zope/annotation/_factory.py
  A   Zope3/branches/jim-adapter/src/zope/annotation/factory.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/annotation/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/annotation/__init__.py	2006-04-06 19:03:04 UTC (rev 66605)
+++ Zope3/branches/jim-adapter/src/zope/annotation/__init__.py	2006-04-06 19:04:54 UTC (rev 66606)
@@ -15,7 +15,6 @@
 
 $Id$
 """
-
 from zope.annotation.interfaces import IAttributeAnnotatable
 from zope.annotation.interfaces import IAnnotations
-from zope.annotation._factory import factory
+from zope.annotation.factory import factory

Deleted: Zope3/branches/jim-adapter/src/zope/annotation/_factory.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/annotation/_factory.py	2006-04-06 19:03:04 UTC (rev 66605)
+++ Zope3/branches/jim-adapter/src/zope/annotation/_factory.py	2006-04-06 19:04:54 UTC (rev 66606)
@@ -1,33 +0,0 @@
-import zope.component
-import zope.interface
-from zope.annotation.interfaces import IAnnotations
-import zope.app.container.contained
-
-def factory(factory, key=None):
-    """Adapter factory to help create annotations easily.
-    """
-    # if no key is provided,
-    # we'll determine the unique key based on the factory's dotted name
-    if key is None:
-        key = factory.__module__ + '.' + factory.__name__
-
-    adapts = zope.component.adaptedBy(factory)
-    if adapts is None:
-        raise TypeError("Missing 'zope.component.adapts' on annotation")
-
-    @zope.component.adapter(list(adapts)[0])
-    @zope.interface.implementer(list(zope.component.implementedBy(factory))[0])
-    def getAnnotation(context):
-        annotations = IAnnotations(context)
-        try:
-            return annotations[key]
-        except KeyError:
-            result = factory()
-            annotations[key] = result
-            zope.app.container.contained.contained(
-                result, context, key)
-            return result
-
-    # Convention to make adapter introspectable, used by apidoc
-    getAnnotation.factory = factory 
-    return getAnnotation

Copied: Zope3/branches/jim-adapter/src/zope/annotation/factory.py (from rev 66599, Zope3/branches/jim-adapter/src/zope/annotation/_factory.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/annotation/_factory.py	2006-04-06 18:50:02 UTC (rev 66599)
+++ Zope3/branches/jim-adapter/src/zope/annotation/factory.py	2006-04-06 19:04:54 UTC (rev 66606)
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Annotation factory helper
+
+$Id$
+"""
+import zope.component
+import zope.interface
+from zope.annotation.interfaces import IAnnotations
+import zope.app.container.contained
+
+def factory(factory, key=None):
+    """Adapter factory to help create annotations easily.
+    """
+    # if no key is provided,
+    # we'll determine the unique key based on the factory's dotted name
+    if key is None:
+        key = factory.__module__ + '.' + factory.__name__
+
+    adapts = zope.component.adaptedBy(factory)
+    if adapts is None:
+        raise TypeError("Missing 'zope.component.adapts' on annotation")
+
+    @zope.component.adapter(list(adapts)[0])
+    @zope.interface.implementer(list(zope.component.implementedBy(factory))[0])
+    def getAnnotation(context):
+        annotations = IAnnotations(context)
+        try:
+            return annotations[key]
+        except KeyError:
+            result = factory()
+            annotations[key] = result
+            zope.app.container.contained.contained(
+                result, context, key)
+            return result
+
+    # Convention to make adapter introspectable, used by apidoc
+    getAnnotation.factory = factory 
+    return getAnnotation


Property changes on: Zope3/branches/jim-adapter/src/zope/annotation/factory.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Zope3-Checkins mailing list