[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/component/site.
Updated to reflect new registration apis.
Jim Fulton
jim at zope.com
Fri Apr 21 16:49:18 EDT 2006
Log message for revision 67259:
Updated to reflect new registration apis.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/component/site.py
U Zope3/branches/jim-adapter/src/zope/app/component/site.txt
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/component/site.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/site.py 2006-04-21 20:12:14 UTC (rev 67258)
+++ Zope3/branches/jim-adapter/src/zope/app/component/site.py 2006-04-21 20:49:17 UTC (rev 67259)
@@ -408,4 +408,4 @@
next = None
if event.newParent is not None:
next = _findNextSiteManager(site)
- site.getSiteManager().setNext(next)
+ site.getSiteManager().__bases__ = (next, )
Modified: Zope3/branches/jim-adapter/src/zope/app/component/site.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/site.txt 2006-04-21 20:12:14 UTC (rev 67258)
+++ Zope3/branches/jim-adapter/src/zope/app/component/site.txt 2006-04-21 20:49:17 UTC (rev 67259)
@@ -143,22 +143,12 @@
... return "%s('%s')" %(self.__class__.__name__, self.title)
Now we can create an instance of our utility and put it in the site
-management folder:
+management folder and register it:
>>> myutil = MyUtility('My custom utility')
>>> default['myutil'] = myutil
+ >>> sm.registerUtility(myutil, IMyUtility, 'u1')
-Then we have to create a registration for the utility and activate it:
-
- >>> reg = site.UtilityRegistration('u1', IMyUtility, myutil)
- >>> default.registrationManager.addRegistration(reg)
- 'UtilityRegistration'
- >>> reg.status = interfaces.registration.ActiveStatus
-
-Note that you can only change the status *after* you have added the
-registration to the registration manager, since registration component uses
-its location to determine the correct registry to add the component to.
-
Now we can ask the site manager for the utility:
>>> sm.queryUtility(IMyUtility, 'u1')
@@ -170,7 +160,7 @@
>>> gutil = MyUtility('Global Utility')
>>> from zope.app import zapi
>>> gsm = zapi.getGlobalSiteManager()
- >>> gsm.provideUtility(IMyUtility, gutil, 'gutil')
+ >>> gsm.registerUtility(gutil, IMyUtility, 'gutil')
>>> sm.queryUtility(IMyUtility, 'gutil')
MyUtility('Global Utility')
@@ -246,7 +236,7 @@
If we ask the second site manager for its next, we get
- >>> sm11.next is sm
+ >>> sm11.__bases__ == (sm, )
True
and the first site manager should have the folling sub manager:
@@ -261,10 +251,7 @@
>>> myutil11 = MyUtility('Utility, uno & uno')
>>> default11['myutil'] = myutil11
- >>> reg11 = site.UtilityRegistration('u1', IMyUtility, myutil11)
- >>> default11.registrationManager.addRegistration(reg11)
- 'UtilityRegistration'
- >>> reg11.status = interfaces.registration.ActiveStatus
+ >>> sm11.registerUtility(myutil11, IMyUtility, 'u1')
then it will will be available in the second site manager
@@ -296,8 +283,10 @@
that manage the wiring of site managers after moving or copying:
>>> from zope.app import container
- >>> gsm.subscribe((interfaces.ISite, container.interfaces.IObjectMovedEvent),
- ... None, site.changeSiteConfigurationAfterMove)
+ >>> gsm.registerHandler(
+ ... site.changeSiteConfigurationAfterMove,
+ ... (interfaces.ISite, container.interfaces.IObjectMovedEvent),
+ ... )
We only have to register one event listener, since the copy action causes an
`IObjectAddedEvent` to be created, which is just a special type of
@@ -305,7 +294,7 @@
First, make sure that everything is setup correctly in the first place:
- >>> myfolder11.getSiteManager().next is myfolder.getSiteManager()
+ >>> myfolder11.getSiteManager().__bases__ == (myfolder.getSiteManager(), )
True
>>> myfolder.getSiteManager().subs[0] is myfolder11.getSiteManager()
True
@@ -320,7 +309,7 @@
Now the next site manager for `myfolder11`'s site manager should have changed:
>>> myfolder21 = myfolder11
- >>> myfolder21.getSiteManager().next is myfolder2.getSiteManager()
+ >>> myfolder21.getSiteManager().__bases__ == (myfolder2.getSiteManager(), )
True
>>> myfolder2.getSiteManager().subs[0] is myfolder21.getSiteManager()
True
@@ -342,7 +331,7 @@
>>> myfolder['myfolder11'] = locationCopy(myfolder2['myfolder21'])
>>> myfolder11 = myfolder['myfolder11']
- >>> myfolder11.getSiteManager().next is myfolder.getSiteManager()
+ >>> myfolder11.getSiteManager().__bases__ == (myfolder.getSiteManager(), )
True
>>> myfolder.getSiteManager().subs[0] is myfolder11.getSiteManager()
True
More information about the Zope3-Checkins
mailing list