[Zope-Checkins] SVN: Products.Five/trunk/ Support and tests for site migration from Five.site to Five.component.

2006-07-27 Thread Lennart Regebro
Log message for revision 69269:
  Support and tests for site migration from Five.site to Five.component.
  

Changed:
  U   Products.Five/trunk/CHANGES.txt
  U   Products.Five/trunk/doc/localsite.txt
  U   Products.Five/trunk/site/browser.py
  U   Products.Five/trunk/site/managesite.pt
  U   Products.Five/trunk/site/tests/test_localsite.py
  U   Products.Five/trunk/site/tests/test_utility.py

-=-
Modified: Products.Five/trunk/CHANGES.txt
===
--- Products.Five/trunk/CHANGES.txt 2006-07-27 10:03:20 UTC (rev 69268)
+++ Products.Five/trunk/CHANGES.txt 2006-07-27 12:33:37 UTC (rev 69269)
@@ -24,7 +24,8 @@
   (and not on attributes).
 
 * The FiveSiteManager classes now work again, but are deprecated for the
-  new zope.component support.
+  new zope.component support. There is also a method to migrate Five.site
+  to zope.component.
 
 Five 1.5c (2006-05-29)
 ==

Modified: Products.Five/trunk/doc/localsite.txt
===
--- Products.Five/trunk/doc/localsite.txt   2006-07-27 10:03:20 UTC (rev 
69268)
+++ Products.Five/trunk/doc/localsite.txt   2006-07-27 12:33:37 UTC (rev 
69269)
@@ -42,8 +42,15 @@
 or programmatically through enableLocalSiteHook(site) turn it into a site.
 
 The new setup involves calling enableSite(site) and createing and setting
-a site manager. The simplest way to do this programatically is to look 
-up the components.html view on the site, and calling view.makeSite().
+a site manager. The simplest way to do this manually is to go to the 
+components.html view of the object you want to make a site, and press the
+Make site button. The easist way to do this programmatically, is to look 
+up the components.html view on the site, and calling view.makeSite():
+
+components_view = queryMultiAdapter((self.context, self.request), 
+ Interface, 'components.html')
+components_view.makeSite()
+
 As any ObjectManager can be a site there is no longer any need to specially
 mark the class as being a possible site.
 
@@ -62,7 +69,9 @@
 Migrating the actual sites
 ..
 
-Not Yet Implemented.
+Go to the object of the site, and add manage_site.html to the URL to open
+the old site management view. There you have a button 
+Migrate to Five.component. Press it to migrate the site.
 
 Experimental forwards compatibility
 ...
@@ -76,7 +85,7 @@
 
 
 Old site implementation details

+===
 
 The rest of this document documents the details of the old site implementation.
 Everything from here on concerns only the old implementation and is of mainly

Modified: Products.Five/trunk/site/browser.py
===
--- Products.Five/trunk/site/browser.py 2006-07-27 10:03:20 UTC (rev 69268)
+++ Products.Five/trunk/site/browser.py 2006-07-27 12:33:37 UTC (rev 69269)
@@ -16,7 +16,9 @@
 $Id$
 
 from zope.app.component.interfaces import ISite
-from zope.app.component.hooks import clearSite
+from zope.app.component.hooks import clearSite, setSite
+from zope.component import getSiteManager, queryMultiAdapter
+from zope.interface import Interface, providedBy
 
 from Products.Five.browser import BrowserView
 from Products.Five.site.localsite import enableLocalSiteHook, 
disableLocalSiteHook
@@ -31,10 +33,16 @@
 self.makeSite()
 elif form.has_key('UPDATE_UNMAKESITE'):
 self.unmakeSite()
+elif form.has_key('UPDATE_MIGRATE'):
+self.migrateToFive15()
 
 def isSite(self):
 return ISite.providedBy(self.context)
 
+def isOldSite(self):
+from Products.Five.site.interfaces import IFiveSiteManager
+return self.isSite() and IFiveSiteManager.providedBy(getSiteManager())
+
 def makeSite(self):
 Convert a possible site to a site
 if self.isSite():
@@ -58,3 +66,30 @@
 clearSite()
 
 return This object is no longer a site
+
+def migrateToFive15(self):
+all_utilities = self.context.utilities.objectItems()
+
+self.unmakeSite()
+self.context.manage_delObjects(['utilities'])
+components_view = queryMultiAdapter((self.context, self.request), 
+Interface, 'components.html')
+components_view.makeSite()
+setSite(self.context)
+
+site_manager = getSiteManager()
+for id, utility in all_utilities:
+info = id.split('-')
+if len(info) == 1:
+name = ''
+else:
+name = info[1]
+interface_name = info[0]
+
+for iface in providedBy(utility):
+if iface.getName() == interface_name:
+site_manager.registerUtility(utility, iface, name=name)
+
+  

[Zope-Checkins] SVN: Products.Five/trunk/ Now you can use the old registry with the new API for registerig components.

2006-07-27 Thread Lennart Regebro
Log message for revision 69271:
  Now you can use the old registry with the new API for registerig components.
  BBB support shold be pretty much complete.
  

Changed:
  U   Products.Five/trunk/doc/localsite.txt
  U   Products.Five/trunk/site/localsite.py
  U   Products.Five/trunk/site/tests/test_utility.py

-=-
Modified: Products.Five/trunk/doc/localsite.txt
===
--- Products.Five/trunk/doc/localsite.txt   2006-07-27 13:51:25 UTC (rev 
69270)
+++ Products.Five/trunk/doc/localsite.txt   2006-07-27 14:15:46 UTC (rev 
69271)
@@ -89,10 +89,8 @@
 
 The rest of this document documents the details of the old site implementation.
 Everything from here on concerns only the old implementation and is of mainly
-hysterical interest:
+hysterical interest.
 
-
-
 By default, Zope 3 has a global site which is configured through ZCML.
 It provides the fallback for all component look-up.  Local sites are
 typically set during traversal, when the traverser encounters an

Modified: Products.Five/trunk/site/localsite.py
===
--- Products.Five/trunk/site/localsite.py   2006-07-27 13:51:25 UTC (rev 
69270)
+++ Products.Five/trunk/site/localsite.py   2006-07-27 14:15:46 UTC (rev 
69271)
@@ -16,12 +16,26 @@
 $Id$
 
 from zope.interface import implements
+from zope.interface.interface import InterfaceClass
 from zope.component import getGlobalSiteManager
 from zope.component.interfaces import ComponentLookupError
 from zope.app.component.interfaces import ISite, IPossibleSite
 from Acquisition import aq_parent, aq_inner
 from Products.Five.site.interfaces import IFiveSiteManager, 
IFiveUtilityRegistry
 
+from operator import xor
+def one_of_three(a, b, c):
+# Logical table for a three part test where only one can be true:
+# 0 0 0: 0
+# 0 0 1: 1
+# 0 1 0: 1
+# 0 1 1: 0
+# 1 0 0: 1
+# 1 0 1: 0
+# 1 1 0: 0
+# 1 1 1: 0
+return xor(xor(a, b), c) and not (a and b and c)
+
 class FiveSiteManager(object):
 implements(IFiveSiteManager)
 
@@ -89,7 +103,56 @@
 def getAllUtilitiesRegisteredFor(self, interface):
 return self.utilities.getAllUtilitiesRegisteredFor(interface)
 
-def registerUtility(self, interface, utility, name=''):
+def registerUtility(self, *args, **kw):
+# Can be called with new API:
+#   component, provided=None, name=u'', info=u'', event=True
+# where info and event are ignored, or old api:
+#   interface, utility, name=''
+name = kw.get('name', u'')
+interface_kw = kw.get('interface', None)
+provided_kw = kw.get('provided', None)
+utility_kw = kw.get('utility', None)
+component_kw = kw.get('component', None)
+
+interface = None  
+utility = None
+if len(args)  0:
+# Positional argument 1
+if isinstance(args[0], InterfaceClass):
+interface = args[0]
+else:
+utility = args[0]
+
+if len(args)  1:
+if isinstance(args[1], InterfaceClass):
+interface = args[1]
+else:
+utility = args[1]
+
+if len(args)  2:
+if name:
+raise TypeError(You can only provide one name)
+else:
+name = args[2]
+
+if not one_of_three(interface is not None, 
+interface_kw is not None,
+provided_kw is not None):
+raise TypeError(You can specify one and only one interface)
+if interface is None:
+interface = interface_kw
+if interface is None:
+interface = provided_kw
+
+if not one_of_three(utility is not None, 
+utility_kw is not None,
+component_kw is not None):
+raise TypeError(You can specify one and only one interface)
+if utility is None:
+utility = utility_kw
+if utility is None:
+utility = component_kw
+
 return self.utilities.registerUtility(interface, utility, name)
 
 class FiveSite:
@@ -121,9 +184,8 @@
 def disableLocalSiteHook(obj):
 Remove __before_traverse__ hook for Local Site
 
-warnings.warn(The disableLocalSiteHook is deprecated and will be removed 
-  in Zope 2.12. \nSee Five/doc/localsite.txt .,
-  DeprecationWarning, 2)
+# This method is of course deprecated too, but issuing a warning is
+# silly.
 disableSite(obj)
 clearSite()
 obj.setSiteManager(None)

Modified: Products.Five/trunk/site/tests/test_utility.py
===
--- Products.Five/trunk/site/tests/test_utility.py  2006-07-27 13:51:25 UTC 
(rev 69270)
+++ 

[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt Note release which contained Jim's GC work for acquisition wrappers.

2006-07-27 Thread Tres Seaver
Log message for revision 69272:
  Note release which contained Jim's GC work for acquisition wrappers.

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-07-27 14:15:46 UTC 
(rev 69271)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-07-27 19:43:07 UTC 
(rev 69272)
@@ -415,6 +415,9 @@
   - Made WebDAV server distinguishable from the default HTTP
 server both in the ZMI and in event.log.
 
+  - Made Acquisition and derived classes play inside Python's acyclic
+garbage collection framework.
+
   - Included BTreeFolder2
 
 Bugs fixed

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.9/doc/CHANGES.txt Jim's GC work for acquisition wrappers.

2006-07-27 Thread Tres Seaver
Log message for revision 69273:
  Jim's GC work for acquisition wrappers.

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-07-27 19:43:07 UTC (rev 69272)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-07-27 19:44:01 UTC (rev 69273)
@@ -4,16 +4,6 @@
   Change information for previous versions of Zope can be found in the
   file HISTORY.txt.
 
-  To-do
-
-   - Add cyclic-garbage collection support to C extension classes,
- especially to acquisition wrappers.
-
- N.B:  ExtensionClassType already declares that it supports GC
- (via the Py_TPFLAGS_HAVE_GC flag), but does not appear to conform
- to the rules for such a type laid out in the Python docs:
- http://docs.python.org/api/supporting-cycle-detection.html
-
   Zope 2.9.5 (unreleased)
 
Bugs fixed

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/doc/CHANGES.txt Note Jim's GC work for acquisition wrappers (landed in 2.8.0b2).

2006-07-27 Thread Tres Seaver
Log message for revision 69275:
  Note Jim's GC work for acquisition wrappers (landed in 2.8.0b2).

Changed:
  U   Zope/trunk/doc/CHANGES.txt

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2006-07-27 19:46:12 UTC (rev 69274)
+++ Zope/trunk/doc/CHANGES.txt  2006-07-27 19:53:36 UTC (rev 69275)
@@ -4,16 +4,6 @@
   Change information for previous versions of Zope can be found in the
   file HISTORY.txt.
 
-  To-do
-
-   - Add cyclic-garbage collection support to C extension classes,
- especially to acquisition wrappers.
-
- N.B:  ExtensionClassType already declares that it supports GC
- (via the Py_TPFLAGS_HAVE_GC flag), but does not appear to conform
- to the rules for such a type laid out in the Python docs:
- http://docs.python.org/api/supporting-cycle-detection.html
-
   Trunk  (unreleased)
 
 Restructuring

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins