Changeset 6963
- Timestamp:
- 29 Oct 2011, 08:15:11 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/hostels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/__init__.py
r6951 r6963 3 3 # Make this a package. 4 4 from waeup.sirp.hostels.container import HostelsContainer 5 from waeup.sirp.hostels.hostel import Hostel 5 from waeup.sirp.hostels.hostel import Hostel, Bed 6 6 7 7 __all__ = [ 8 8 'HostelsContainer', 9 9 'Hostel', 10 'Bed', 10 11 ] -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py
r6954 r6963 21 21 from grok import index 22 22 from waeup.sirp.utils.helpers import attrs_to_fields 23 from waeup.sirp.hostels.interfaces import IHostel 23 from waeup.sirp.hostels.interfaces import IHostel, IBed 24 24 25 25 class Hostel(grok.Container): … … 33 33 return grok.getSite()['hostels'].logger_info(ob_class,target,comment) 34 34 35 def addBed(self, bed): 36 """Add a hostel. 37 """ 38 if not IBed.providedBy(bed): 39 raise TypeError( 40 'Hostels contain only IBed instances') 41 self[hostel.bed_id] = bed 42 return 43 35 44 Hostel = attrs_to_fields(Hostel) 45 46 class Bed(grok.Container): 47 """This is a bed. 48 """ 49 grok.implements(IBed) 50 grok.provides(IBed) 51 52 def getBedCoordinates(self): 53 """Determine the coordinates from bed_id. 54 """ 55 pass 56 57 def loggerInfo(self, ob_class, comment=None): 58 target = self.__name__ 59 return grok.getSite()['hostels'].logger_info(ob_class,target,comment) 60 61 Bed = attrs_to_fields(Bed) -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/interfaces.py
r6959 r6963 81 81 ), 82 82 ) 83 84 class IBed(IWAeUPObject): 85 """A base representation of beds. 86 87 """ 88 89 def loggerInfo(ob_class, comment): 90 """Adds an INFO message to the log file 91 """ 92 93 def getBedCoordinates(): 94 """Determine the coordinates from bed_id. 95 """ 96 97 bed_id = schema.TextLine( 98 title = u'Bed Id', 99 required = True, 100 default = u'', 101 ) 102 103 bed_type = schema.TextLine( 104 title = u'Bed Type', 105 required = True, 106 default = u'', 107 ) 108 109 sort_id = schema.Int( 110 title = u'Sort Id', 111 required = True, 112 default = 100, 113 ) 114 115 owner = schema.TextLine( 116 title = u'Owner (Student)', 117 required = True, 118 default = u'', 119 ) -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py
r6962 r6963 25 25 from waeup.sirp.app import University 26 26 from waeup.sirp.hostels.interfaces import ( 27 IHostelsContainer, IHostel )27 IHostelsContainer, IHostel, IBed) 28 28 from waeup.sirp.hostels.container import HostelsContainer 29 from waeup.sirp.hostels.hostel import Hostel 29 from waeup.sirp.hostels.hostel import Hostel, Bed 30 30 from waeup.sirp.testing import (FunctionalLayer, FunctionalTestCase) 31 31 … … 51 51 verifyObject( 52 52 IHostel, Hostel()) 53 ) 54 self.assertTrue( 55 verifyClass( 56 IBed, Bed) 57 ) 58 self.assertTrue( 59 verifyObject( 60 IBed, Bed()) 53 61 ) 54 62 return
Note: See TracChangeset for help on using the changeset viewer.