[Checkins] SVN: grok/branches/jw-philipp-using-ndir-directives/src/grok/ Get rid of the last remaining uses of the class_annotation helper. Other cleanup.

Philipp von Weitershausen philikon at philikon.de
Sat May 3 11:02:23 EDT 2008


Log message for revision 86230:
  Get rid of the last remaining uses of the class_annotation helper. Other cleanup.

Changed:
  U   grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py
  U   grok/branches/jw-philipp-using-ndir-directives/src/grok/meta.py
  U   grok/branches/jw-philipp-using-ndir-directives/src/grok/util.py

-=-
Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py	2008-05-03 15:01:52 UTC (rev 86229)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/components.py	2008-05-03 15:02:22 UTC (rev 86230)
@@ -663,9 +663,8 @@
 
     def __init__(self, context, request, view):
         super(ViewletManager, self).__init__(context, request, view)
-        self.__name__ = util.class_annotation(self.__class__,
-                                              'grok.name',
-                                              self.__class__.__name__.lower())
+        self.__name__ = util.get_name_classname(self.__class__)
+
         self.static = component.queryAdapter(
             self.request,
             interface.Interface,
@@ -718,9 +717,8 @@
         super(Viewlet, self).__init__(context, request, view, manager)
         # would be nice to move this to the ViewletGrokker but
         # new objects don't have __name__ of their class
-        self.__name__ = util.class_annotation(self.__class__,
-                                             'grok.name',
-                                              self.__class__.__name__.lower())
+        self.__name__ = util.get_name_classname(self.__class__)
+
         self.static = component.queryAdapter(
             self.request,
             interface.Interface,

Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/meta.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/meta.py	2008-05-03 15:01:52 UTC (rev 86229)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/meta.py	2008-05-03 15:02:22 UTC (rev 86230)
@@ -51,6 +51,7 @@
 from grok import components, formlib, templatereg
 from grok.util import check_permission, make_checker
 from grok.util import public_methods_from_class
+from grok.util import get_name_classname
 from grok.rest import RestPublisher
 from grok.interfaces import IRESTSkinType
 
@@ -59,14 +60,6 @@
 from grokcore.component.util import determine_module_component
 from grokcore.component.util import check_module_component
 
-#  XXX helper moved back from grokcore.component
-def get_name_classname(factory):
-    name = grok.name.get(factory)
-    if not name:
-        name = factory.__name__.lower()
-    return name
-
-
 class ViewletManagerContextGrokker(martian.GlobalGrokker):
 
     priority = 1001
@@ -514,8 +507,7 @@
     if installed:
         return
 
-    for info in util.class_annotation(site.__class__,
-                                      'grok.utilities_to_install', []):
+    for info in getattr(site.__class__, '__grok_utilities_to_install__', []):
         setupUtility(site, info.factory(), info.provides, name=info.name,
                      name_in_container=info.name_in_container,
                      public=info.public, setup=info.setup)
@@ -574,10 +566,11 @@
         # We can safely convert to unicode, since the directives make sure
         # it is either unicode already or ASCII.
         id = unicode(id)
-        permission = factory(
-            id,
-            unicode(util.class_annotation(factory, 'grok.title', id)),
-            unicode(util.class_annotation(factory, 'grok.description', '')))
+        title = grok.title.get(factory)
+        if not title:
+            title = id
+        permission = factory(id, unicode(title),
+                             unicode(grok.description.get(factory)))
 
         config.action(
             discriminator=('utility', IPermission, id),
@@ -600,10 +593,11 @@
         # We can safely convert to unicode, since the directives makes sure
         # it is either unicode already or ASCII.
         id = unicode(id)
-        role = factory(
-            id,
-            unicode(util.class_annotation(factory, 'grok.title', id)),
-            unicode(util.class_annotation(factory, 'grok.description', '')))
+        title = grok.title.get(factory)
+        if not title:
+            title = id
+        role = factory(id, unicode(title),
+                       unicode(grok.description.get(factory)))
 
         config.action(
             discriminator=('utility', IRole, id),

Modified: grok/branches/jw-philipp-using-ndir-directives/src/grok/util.py
===================================================================
--- grok/branches/jw-philipp-using-ndir-directives/src/grok/util.py	2008-05-03 15:01:52 UTC (rev 86229)
+++ grok/branches/jw-philipp-using-ndir-directives/src/grok/util.py	2008-05-03 15:02:22 UTC (rev 86230)
@@ -16,6 +16,7 @@
 
 import urllib
 
+import grok
 import zope.location.location
 from zope import component
 from zope import interface
@@ -34,6 +35,12 @@
 from grokcore.component.util import sort_components
 from grokcore.component.util import determine_module_component
 
+def get_name_classname(factory):
+    name = grok.name.get(factory)
+    if not name:
+        name = factory.__name__.lower()
+    return name
+
 def public_methods_from_class(factory):
     return [m for m in methods_from_class(factory) if \
             not m.__name__.startswith('_')]



More information about the Checkins mailing list