Changeset 4079 for waeup/branches/ulif-rewrite
- Timestamp:
- 25 Apr 2009, 13:36:17 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/facultycontainer.py
r3925 r4079 1 1 import grok 2 2 from zope.component import getUtility 3 from zope.component.interfaces import Invalid 3 from zope.component.factory import Factory 4 from zope.component.interfaces import Invalid, IFactory 4 5 from zope.exceptions import DuplicationError 6 from zope.interface import implementedBy 5 7 from waeup.interfaces import IFacultyContainer, IFaculty 6 8 from waeup.viewlets import MainArea, LeftSidebar, Index, Add, FormWrapMixin … … 14 16 # A simple counter for ids. 15 17 next_id = 0L 16 18 17 19 def addFaculty(self, faculty): 18 20 if not IFaculty.providedBy(faculty): … … 25 27 return id 26 28 27 # We register FacultyContainer as a utility. This way we can 28 # call getUtility(IFacultyContainer) from anywhere in the code and 29 # get an instance of FacultyContainer. 30 grok.global_utility(FacultyContainer, provides=IFacultyContainer) 29 class FacultyContainerFactory(grok.GlobalUtility): 30 """A factory for faculty containers. 31 """ 32 grok.implements(IFactory) 33 grok.name(u'waeup.FacultyContainer') 34 title = u"Create a new faculty container.", 35 description = u"This factory instantiates new faculty containers." 36 37 def __call__(self): 38 return FacultyContainer() 39 40 def getInterfaces(self): 41 return implementedBy(FacultyContainer) 31 42 32 43 #
Note: See TracChangeset for help on using the changeset viewer.