Changeset 5722 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 12 Feb 2011, 11:52:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/jambtables/jambtables.py
r5689 r5722 34 34 from BTrees.Length import Length 35 35 36 from waeup.sirp.applicants.jambtables.interfaces import IJAMBDataTable 36 from waeup.sirp.interfaces import IWAeUPSIRPPluggable 37 from waeup.sirp.applicants.jambtables.interfaces import ( 38 IJAMBDataTable, IJAMBDataRoot 39 ) 37 40 38 41 #: The header fields required for a valid JAMB table CSV file. … … 180 183 os.mkdir(jambtable_storage) 181 184 return os.path.abspath(jambtable_storage) 185 186 class JAMBDataRoot(grok.Container): 187 grok.implements(IJAMBDataRoot) 188 189 class JAMBDataPlugin(grok.GlobalUtility): 190 """A WAeUPSIRPPlugin that creates a JAMB data root in portal. 191 192 This plugin should be called by a typical 193 `waeup.sirp.app.Universtiy` instance on creation time. The 194 :meth:`update` method normally can also be triggered manually over 195 the main site configuration. 196 197 Implements :class:`waeup.sirp.interfaces.IWAeUPSIRPPluggable` 198 """ 199 grok.name('jambdata') 200 grok.implements(IWAeUPSIRPPluggable) 201 log_prefix = 'JAMBDataPlugin' 202 203 def setup(self, site, name, logger): 204 """Create a new :class:`ApplicantsRoot` instance in `site`. 205 """ 206 site['jambdata'] = JAMBDataRoot() 207 logger.info( 208 '%s: Installed JAMB data root.' % (self.log_prefix,) 209 ) 210 return 211 212 def update(self, site, name, logger): 213 """Update site wide ``jambdata`` root. 214 215 If the site already contains a suitable ``jambdata`` root, 216 leave it that way. If not create one and delete the old one if 217 appropriate. 218 """ 219 jamb_folder = site.get('jambdata', None) 220 site_name = getattr(site, '__name__', '<Unnamed Site>') 221 if IJAMBDataRoot.providedBy(jamb_folder): 222 # JAMB data storage up to date. Return. 223 logger.info( 224 '%s: Updating site at %s: Nothing to do.' % ( 225 self.log_prefix, site_name,) 226 ) 227 return 228 elif jamb_folder is not None: 229 # JAMB data storage needs update. Remove old instance. 230 logger.warn( 231 '%s: Outdated JAMB data folder detected at site %s.' 232 'Removing it.' % (self.log_prefix, site_name) 233 ) 234 del site['jambdata'] 235 # Add new applicants. 236 logger.info( 237 '%s: Updating site at %s. Installing ' 238 'JAMB data folder.' % (self.log_prefix, site_name,) 239 ) 240 self.setup(site, name, logger) 241 return
Note: See TracChangeset for help on using the changeset viewer.