Changeset 5670 for main/waeup.sirp/trunk/src
- Timestamp:
- 25 Jan 2011, 01:10:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applications/root.py
r5648 r5670 24 24 """ 25 25 import grok 26 from waeup.sirp.interfaces import IWAeUPSIRPPluggable 26 27 from waeup.sirp.applications.interfaces import IApplicationsRoot 27 28 … … 30 31 """ 31 32 grok.implements(IApplicationsRoot) 32 33 33 34 def addApplicationContainer(self, container, name=None): 34 35 """Add an application container. … … 37 38 under the name `name`. 38 39 39 `container` the container instance to be added. Should 40 `container` 41 the container instance to be added. Should 40 42 implement :class:`IApplicationContainer`. 41 43 … … 49 51 self[name] = container 50 52 return 53 54 class ApplicationsPlugin(grok.GlobalUtility): 55 """A WAeUPSIRPPlugin that creates an applications root in portal. 56 57 This plugin should be called by a typical 58 `waeup.sirp.app.Universtiy` instance on creation time. The 59 :meth:`update` method normally can also be triggered manually over 60 the main site configuration. 61 62 Implements :class:`waeup.sirp.interfaces.IWAeUPSIRPPluggable` 63 """ 64 grok.name('applications') 65 grok.implements(IWAeUPSIRPPluggable) 66 log_prefix = 'ApplicationsPlugin' 67 68 def setup(self, site, name, logger): 69 """Create a new :class:`ApplicationsRoot` instance in `site`. 70 """ 71 site['applications'] = ApplicationsRoot() 72 logger.info( 73 '%s: Installed applications root.' % (self.log_prefix,) 74 ) 75 return 76 77 def update(self, site, name, logger): 78 """Update site wide ``applications`` root. 79 80 If the site already contains a suitable ``applications`` root, 81 leave it that way. If not create one and delete the old one if 82 appropriate. 83 """ 84 app_folder = site.get('applications', None) 85 site_name = getattr(site, '__name__', 'Unnamed Site?') 86 if IApplicationsRoot.providedBy(app_folder): 87 # Applications up to date. Return. 88 logger.info( 89 '%s: Updating site at %s: Nothing to do.' % ( 90 self.log_prefix, site_name,) 91 ) 92 return 93 elif app_folder is not None: 94 # Applications need update. Remove old instance. 95 logger.warn( 96 '%s: Outdated applications folder detected at site %s.' 97 'Removing it.' % (self.log_prefix, site_name) 98 ) 99 del site['applications'] 100 # Add new applications. 101 logger.info( 102 '%s: Updating site at %s. Installing ' 103 'applications.' % (self.log_prefix, site_name,) 104 ) 105 self.setup(site, name, logger) 106 return
Note: See TracChangeset for help on using the changeset viewer.