[Zope3-checkins] SVN: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/ usign a global singleton

Tarek Ziadé tziade at nuxeo.com
Fri Oct 7 08:22:46 EDT 2005


Log message for revision 38876:
  usign a global singleton

Changed:
  U   Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py
  U   Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py
  U   Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py

-=-
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py	2005-10-07 12:14:52 UTC (rev 38875)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py	2005-10-07 12:22:46 UTC (rev 38876)
@@ -32,18 +32,15 @@
 
 
 def chooseClasses(method, environment):
-    from zope.app.publication.requestpublicationregistry import PublicationRegistry
+    from zope.app.publication.metaconfigure import getFactoryRegistry
 
     content_type = environment.get('CONTENT_TYPE', '')
-    import pdb
-    pdb.set_trace()
-    factory = PublicationRegistry.lookup(method, content_type, environment)
+    factory = getFactoryRegistry().lookup(method, content_type, environment)
+
     if not factory:
         raise RuntimeError('nothing found')
     return factory()
 
-
-
     if method in ('GET', 'POST', 'HEAD'):
         content_type = environment.get('CONTENT_TYPE', '')
         if method == 'POST' and content_type.startswith('text/xml'):

Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py	2005-10-07 12:14:52 UTC (rev 38875)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py	2005-10-07 12:22:46 UTC (rev 38876)
@@ -21,7 +21,6 @@
 
 from zope.app.publication.requestpublicationregistry import RequestPublicationRegistry
 
-
 class RequestPublicationRegisterer(object):
     """ Link a request type to a request-publication factory """
 
@@ -56,8 +55,7 @@
         """ calls the register factory utility, that actually links
             the factory.
         """
-        factory_registerer = RequestPublicationRegistry()
-        registerer = factory_registerer.register
+        registerer = _factory_registerer.register
 
         # need to register all methods<->mimetypes combos here
         # for imbrication: usally there are more methods than mimetypes
@@ -65,5 +63,15 @@
             for mimetype in mimetypes:
                 registerer(method, mimetype, name, priority, factory)
 
+_factory_registerer = None
+
+def getFactoryRegistry():
+    return _factory_registerer
+
 def publisher(_context, name, factory, method='*', mimetype='*', priority=0):
-    RequestPublicationRegisterer(name, factory, method, mimetype, priority)
+
+    global _factory_registerer
+    if _factory_registerer is None:
+        _factory_registerer = RequestPublicationRegistry()
+
+    RequestPublicationRegisterer(name, factory(), method, mimetype, priority)

Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py	2005-10-07 12:14:52 UTC (rev 38875)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py	2005-10-07 12:22:46 UTC (rev 38876)
@@ -78,5 +78,3 @@
                 return factory
 
         return None
-
-PublicationRegistry = RequestPublicationRegistry()



More information about the Zope3-Checkins mailing list