Author: jmorliaguet
Date: Sat Nov  5 10:53:29 2005
New Revision: 29010

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/metaconfigure.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/display.py
Log:

- migrated the display registry to named utilities



Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/__init__.py 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/__init__.py 
Sat Nov  5 10:53:29 2005
@@ -17,10 +17,3 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.component import provideUtility
-
-from cpsskins.configuration import ConfigurationRegistry
-from cpsskins.configuration.interfaces import IRegistry
-
-provideUtility(ConfigurationRegistry(), IRegistry, 'displays')
-

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/metaconfigure.py
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/displays/metaconfigure.py
    Sat Nov  5 10:53:29 2005
@@ -22,13 +22,13 @@
 from zope.app.component.metaconfigure import adapter
 from zope.app.content.interfaces import IContentType
 from zope.configuration.exceptions import ConfigurationError
-from zope.component import getUtility
+from zope.component import queryUtility, provideUtility
 from zope.interface import alsoProvides
 
-from cpsskins.configuration.interfaces import IRegistry
 from cpsskins.elements.interfaces import IDisplay, IElementType, IDisplayType
+from cpsskins.elements.display import Display
 
-display_registry = getUtility(IRegistry, 'displays')
+_marker = object()
 
 def display(_context, name='', schema=None, factory=None):
 
@@ -39,7 +39,7 @@
         raise ConfigurationError(
             "Display names can only contain alphabetic characters.")
 
-    if name in display_registry:
+    if queryUtility(IDisplay, name, _marker) is not _marker:
         raise ConfigurationError, \
             "A display with the name '%s' has already been registered." % name
 
@@ -69,7 +69,7 @@
         )
 
     # register the display
-    display_registry.register(name, {'factory': factory})
+    provideUtility(Display(factory=factory), IDisplay, name)
 
     # set up interface types
     alsoProvides(IDisplay, IElementType)

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        Sat Nov 
 5 10:53:29 2005
@@ -38,12 +38,13 @@
 from cpsskins.storage.interfaces import IDisplayStorage
 from interfaces import IDisplayable, IDisplay, IDisplayType
 
-display_registry = getUtility(IRegistry, 'displays')
-
 class Display(Element):
 
     implements(IDisplay)
 
+    def __init__(self, factory=None):
+        self.factory = factory
+
     def __iter__(self):
         return iter([])
 
@@ -225,7 +226,6 @@
             presentation = queryUtility(IPresentation,
                                         str(IType(context).getElementType()))
 
-        display_name = presentation.display
-        display_factory = display_registry[display_name]['factory']
-        return apply(display_factory, ())
+        display = getUtility(IDisplay, presentation.display)
+        return apply(display.factory, ())
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to