[Checkins] SVN: five.localsitemanager/trunk/ - hardcoded site manager name used by make_site

Yvo Schubbe y.2008 at wcm-solutions.de
Wed Nov 19 03:14:36 EST 2008


Log message for revision 93127:
  - hardcoded site manager name used by make_site
  - added customized __repr__ method to PersistentComponents that returns the path of the site manager

Changed:
  U   five.localsitemanager/trunk/CHANGES.txt
  U   five.localsitemanager/trunk/src/five/localsitemanager/__init__.py
  U   five.localsitemanager/trunk/src/five/localsitemanager/browser.py
  U   five.localsitemanager/trunk/src/five/localsitemanager/registry.py

-=-
Modified: five.localsitemanager/trunk/CHANGES.txt
===================================================================
--- five.localsitemanager/trunk/CHANGES.txt	2008-11-19 02:32:18 UTC (rev 93126)
+++ five.localsitemanager/trunk/CHANGES.txt	2008-11-19 08:14:36 UTC (rev 93127)
@@ -4,6 +4,11 @@
 2.0 - Unreleased
 ----------------
 
+* 'make_site' no longer stores the path of the site manager in its name. This
+  way the name can't become out-dated. PersistentComponents' __repr__ method
+  now returns the current path instead of the name of the site manager.
+  [yuppie]
+
 * Requiring zope.component >= 3.5.0.
   [icemac]
 

Modified: five.localsitemanager/trunk/src/five/localsitemanager/__init__.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/__init__.py	2008-11-19 02:32:18 UTC (rev 93126)
+++ five.localsitemanager/trunk/src/five/localsitemanager/__init__.py	2008-11-19 08:14:36 UTC (rev 93127)
@@ -1,3 +1,20 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""Local site manager for Zope 2.
+
+$Id$
+"""
+
 from Acquisition import aq_base
 from zope.component.globalregistry import base
 from zope.traversing.interfaces import IContainmentRoot
@@ -14,23 +31,17 @@
     """
     if ISite.providedBy(obj):
         raise ValueError('This is already a site')
-    
+
     next = find_next_sitemanager(obj)
     if next is None:
         next = base
 
     enableSite(obj, iface=iface)
 
-    name = 'five'
-    path = getattr(obj, 'getPhysicalPath', None)
-    if path is not None and callable(path):
-        name = '/'.join(path())
-
-    components = PersistentComponents(name=name, bases=(next,))
+    components = PersistentComponents('++etc++site', bases=(next,))
     obj.setSiteManager(components)
     components.__parent__ = aq_base(obj)
 
-
 def make_objectmanager_site(obj):
     """Just a bit of sugar coating to make an unnofficial objectmanager
     based site.

Modified: five.localsitemanager/trunk/src/five/localsitemanager/browser.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/browser.py	2008-11-19 02:32:18 UTC (rev 93126)
+++ five.localsitemanager/trunk/src/five/localsitemanager/browser.py	2008-11-19 08:14:36 UTC (rev 93127)
@@ -1,3 +1,21 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""Management view for local site manager.
+
+$Id$
+"""
+
+from zope.app.component.hooks import setSite
 from zope.component.globalregistry import base
 from five.localsitemanager import make_objectmanager_site
 
@@ -10,6 +28,7 @@
 
     def makeSite(self):
         make_objectmanager_site(self.context)
+        setSite(self.context)
 
     def sitemanagerTrail(self):
         if not self.isSite():

Modified: five.localsitemanager/trunk/src/five/localsitemanager/registry.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/registry.py	2008-11-19 02:32:18 UTC (rev 93126)
+++ five.localsitemanager/trunk/src/five/localsitemanager/registry.py	2008-11-19 08:14:36 UTC (rev 93127)
@@ -1,3 +1,20 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""Component registry for local site manager.
+
+$Id$
+"""
+
 import Acquisition
 import persistent
 import OFS.ObjectManager
@@ -190,6 +207,18 @@
         utilities._createLookup()
         utilities.__parent__ = self
 
+    def __repr__(self):
+        url = 'five'
+        site = Acquisition.aq_base(self.__parent__)
+        try:
+            site = _wrap(site, self)
+        except (ValueError, TypeError):
+            pass
+        path = getattr(site, 'getPhysicalPath', None)
+        if path is not None and callable(path):
+            url = '/'.join(path())
+        return "<%s %s>" % (self.__class__.__name__, url)
+
     def registeredUtilities(self):
         for reg in super(PersistentComponents, self).registeredUtilities():
             reg.component=_wrap(reg.component, self)



More information about the Checkins mailing list