Author: jmorliaguet
Date: Fri Nov  4 23:08:27 2005
New Revision: 29006

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/metaconfigure.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/presentations/metaconfigure.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/display.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py
Log:

- converted the engine registry to a utility

- the elements interface's name is used as a dotted name to register
  presentations associated to elements



Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/__init__.py  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/__init__.py  
Fri Nov  4 23:08:27 2005
@@ -11,20 +11,14 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Rendering engine traverser /++engine++name
 
 $Id$
 """
-__docformat__ = "reStructuredText"
 
-"""Rendering engine traverser /++engine++name
-"""
+__docformat__ = "reStructuredText"
 
 from zope.app.traversing.namespace import view
-from zope.component import provideUtility
-
-from cpsskins.configuration import ConfigurationRegistry
-from cpsskins.configuration.interfaces import IRegistry
 
 # ++engine++ traverser
 class engine(view):
@@ -34,5 +28,3 @@
 
         return self.context
 
-# engine registry
-provideUtility(ConfigurationRegistry(), IRegistry, 'engines')

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/metaconfigure.py 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/engines/metaconfigure.py 
    Fri Nov  4 23:08:27 2005
@@ -17,17 +17,18 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.component import getUtility
+from zope.component import queryUtility, provideUtility
 from zope.configuration.exceptions import ConfigurationError
 
-from cpsskins.configuration.interfaces import IRegistry
+from cpsskins.elements.interfaces import IEngine
+from cpsskins.elements.engine import Engine
 
-renderer_registry = getUtility(IRegistry, 'engines')
+_marker = object()
 
 def engine(_context, name, accesskeys=[]):
 
-    if name in renderer_registry:
+    if queryUtility(IEngine, name, _marker) is not _marker:
         raise ConfigurationError(
             "The '%s' engine has already been registered." % name)
 
-    renderer_registry.register(name, {'accesskeys': accesskeys})
+    provideUtility(Engine(accesskeys=accesskeys), IEngine, name)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/presentations/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/presentations/metaconfigure.py
       (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/presentations/metaconfigure.py
       Fri Nov  4 23:08:27 2005
@@ -17,7 +17,7 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.component import getUtility, provideUtility
+from zope.component import queryUtility, provideUtility
 from zope.configuration.exceptions import ConfigurationError
 from zope.i18nmessageid import MessageFactory
 
@@ -26,6 +26,8 @@
 
 _ = MessageFactory("cpsskins")
 
+_marker = object()
+
 class PresentationDirective(object):
 
     def __init__(self, _context, for_):
@@ -42,10 +44,17 @@
 
     def __call__(self):
 
+        name = str(self.for_)
+
+        if queryUtility(IPresentation, name, _marker) is not _marker:
+            raise ConfigurationError(
+                "A presentation has already been registered for the"
+                "interface %s" % self.for_)
+
         if not self._display:
             raise ConfigurationError("Must specify a display type.")
 
         provideUtility(
             Presentation(display=self._display, formats=self._formats),
-            IPresentation, self.for_.__name__)
+            IPresentation, name)
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/display.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/display.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/display.py        Fri Nov 
 4 23:08:27 2005
@@ -219,10 +219,11 @@
         """
         context = self.context
 
-        type = IType(context)
-        presentation = queryUtility(IPresentation, type.contenttype())
+        presentation = queryUtility(IPresentation,
+                                    str(IType(context).getContentType()))
         if presentation is None:
-            presentation = queryUtility(IPresentation, type.elementtype())
+            presentation = queryUtility(IPresentation,
+                                        str(IType(context).getElementType()))
 
         display_name = presentation.display
         display_factory = display_registry[display_name]['factory']

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py     Fri Nov 
 4 23:08:27 2005
@@ -137,6 +137,9 @@
     def storeFormat(format):
         """Add a format to the format storage."""
 
+class IEngine(Interface):
+    """A rendering engine."""
+
 class IPresentation(Interface):
     """A Presentation."""
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py   Fri Nov 
 4 23:08:27 2005
@@ -67,11 +67,11 @@
 
         formattable = IFormattable(display)
 
-        type = IType(context)
-
-        factory_info = queryUtility(IPresentation, type.contenttype())
+        factory_info = queryUtility(IPresentation,
+                                    str(IType(context).getContentType()))
         if factory_info is None:
-            factory_info = queryUtility(IPresentation, type.elementtype())
+            factory_info = queryUtility(IPresentation,
+                                    str(IType(context).getElementType()))
         for type, id in factory_info.formats.items():
             formattable.addFormat(type, id)
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to