[Checkins] SVN: GenericSetup/branches/1.3/ correct the object path for the site root to be the empty string when exporting components

Wichert Akkerman wichert at wiggy.net
Tue Aug 7 04:56:17 EDT 2007


Log message for revision 78654:
  correct the object path for the site root to be the empty string when exporting components

Changed:
  U   GenericSetup/branches/1.3/CHANGES.txt
  U   GenericSetup/branches/1.3/components.py

-=-
Modified: GenericSetup/branches/1.3/CHANGES.txt
===================================================================
--- GenericSetup/branches/1.3/CHANGES.txt	2007-08-07 05:35:34 UTC (rev 78653)
+++ GenericSetup/branches/1.3/CHANGES.txt	2007-08-07 08:56:17 UTC (rev 78654)
@@ -3,6 +3,9 @@
 
   GenericSetup 1.3.1 (unreleased)
 
+    - components: correct the object path for the site root to be the
+      empty string.
+
     - components: Made output more diff friendly.
 
     - utils: Added warnings to old code.
@@ -12,7 +15,7 @@
 
     - components: Added 'components_xmlconfig.html' form.
       This view allows to inspect and edit component registrations. It is also
-      as ZMI tab 'manage_components' available.
+      available under the ZMI tab 'manage_components'.
 
 
   GenericSetup 1.3 (2007/07/26)

Modified: GenericSetup/branches/1.3/components.py
===================================================================
--- GenericSetup/branches/1.3/components.py	2007-08-07 05:35:34 UTC (rev 78653)
+++ GenericSetup/branches/1.3/components.py	2007-08-07 08:56:17 UTC (rev 78654)
@@ -118,7 +118,15 @@
                                          provided=provided,
                                          name=name)
 
+    def _getSite(self):
+        # Get the site by either __parent__ or Acquisition
+        site = getattr(self.context, '__parent__', None)
+        if site is None:
+            site = aq_parent(self.context)
+        return site
+
     def _initUtilities(self, node):
+        site = self._getSite()
         for child in node.childNodes:
             if child.nodeName != 'utility':
                 continue
@@ -134,10 +142,6 @@
 
             obj_path = child.getAttribute('object')
             if not component and not factory and obj_path is not None:
-                # Get the site by either __parent__ or Acquisition
-                site = getattr(self.context, '__parent__', None)
-                if site is None:
-                    site = aq_parent(self.context)
                 # Support for registering the site itself
                 if obj_path in ('', '/'):
                     obj = site
@@ -201,8 +205,10 @@
                           for reg in self.context.registeredUtilities() ]
         registrations.sort(key=itemgetter('name'))
         registrations.sort(key=itemgetter('provided'))
+        site = aq_base(self._getSite())
 
         for reg_info in registrations:
+            import pdb ; pdb.set_trace()
             child = self._doc.createElement('utility')
 
             child.setAttribute('interface', reg_info['provided'])
@@ -214,7 +220,10 @@
             # check if the component is acquisition wrapped. If it is, export
             # an object reference instead of a factory reference
             if getattr(comp, 'aq_base', None) is not None:
-                child.setAttribute('object', comp.getId())
+                if aq_base(comp) is site:
+                    child.setAttribute('object', '')
+                else:
+                    child.setAttribute('object', comp.getId())
             else:
                 factory = _getDottedName(type(comp))
                 child.setAttribute('factory', factory)



More information about the Checkins mailing list