Changeset 15708 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 28 Oct 2019, 22:37:30 (5 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/app.py
r15422 r15708 88 88 """ 89 89 for name in ['faculties', 'departments', 'certificates', 90 'certcourses', 'courses', 90 'certcourses', 'courses', 'hostels', 91 91 'site-pluggable-auth']: 92 92 getUtility(IKofaPluggable, name=name).update( -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/catalog.py
r13316 r15708 32 32 bed_type = index.Field(attribute='bed_type') 33 33 owner = index.Field(attribute='owner') 34 bed_id = index.Field(attribute='bed_id') -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py
r15633 r15708 22 22 from zope.event import notify 23 23 from zope.component import getUtility, createObject 24 from zope.component.interfaces import IFactory 24 from zope.component.interfaces import IFactory, ComponentLookupError 25 from zope.catalog.interfaces import ICatalog 26 from zope.catalog.field import FieldIndex 25 27 from datetime import datetime 26 28 from waeup.kofa.utils.helpers import attrs_to_fields … … 28 30 from waeup.kofa.hostels.interfaces import IHostel, IBed 29 31 from waeup.kofa.students.interfaces import IBedTicket 30 from waeup.kofa.interfaces import IKofaUtils 32 from waeup.kofa.interfaces import IKofaUtils, IKofaPluggable 31 33 from waeup.kofa.interfaces import MessageFactory as _ 32 34 from waeup.kofa.utils.helpers import now … … 325 327 return implementedBy(Bed) 326 328 329 class HostelsPlugin(grok.GlobalUtility): 330 """A plugin to update beds_catalog 331 """ 332 grok.implements(IKofaPluggable) 333 grok.name('hostels') 334 log_prefix = 'HostelsPlugin' 335 336 def setup(self, site, name, logger): 337 return 338 339 def update(self, site, name, logger): 340 site_name = getattr(site, '__name__', '<Unnamed Site>') 341 nothing_to_do = True 342 # Add bed_id index 343 try: 344 cat = getUtility(ICatalog, name='beds_catalog') 345 if 'bed_id' not in cat.keys(): 346 nothing_to_do = False 347 cat[u'bed_id'] = FieldIndex(field_name=u'bed_id') 348 cat.updateIndexes() 349 logger.info( 350 '%s: bed_id index added to beds_catalog.' 351 % self.log_prefix) 352 except ComponentLookupError: # in unit tests 353 pass 354 if nothing_to_do: 355 logger.info( 356 '%s: Updating site at %s: Nothing to do.' % ( 357 self.log_prefix, site_name,) 358 ) 359 return 360 327 361 328 362 @grok.subscribe(IBedTicket, grok.IObjectRemovedEvent)
Note: See TracChangeset for help on using the changeset viewer.