Changeset 4079 for waeup/branches


Ignore:
Timestamp:
25 Apr 2009, 13:36:17 (16 years ago)
Author:
uli
Message:

Use real factories for FacultyContainer?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/university/facultycontainer.py

    r3925 r4079  
    11import grok
    22from zope.component import getUtility
    3 from zope.component.interfaces import Invalid
     3from zope.component.factory import Factory
     4from zope.component.interfaces import Invalid, IFactory
    45from zope.exceptions import DuplicationError
     6from zope.interface import implementedBy
    57from waeup.interfaces import IFacultyContainer, IFaculty
    68from waeup.viewlets import MainArea, LeftSidebar, Index, Add, FormWrapMixin
     
    1416    # A simple counter for ids.
    1517    next_id = 0L
    16    
     18
    1719    def addFaculty(self, faculty):
    1820        if not IFaculty.providedBy(faculty):
     
    2527        return id
    2628
    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)
     29class 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)
    3142
    3243#
Note: See TracChangeset for help on using the changeset viewer.