Ignore:
Timestamp:
1 Jan 2009, 16:45:08 (16 years ago)
Author:
uli
Message:

Use utility lookups instead of imported classes to populate the university app.

File:
1 edited

Legend:

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

    r3530 r3830  
    11import grok
    22from grok import index
     3from zope.component import getUtility
    34from zope.interface import Interface
    4 from interfaces import IUniversity
    5 from setup import app_setup
    6 from viewlets import MainArea
     5
     6from waeup.interfaces import (IUniversity, IStudentContainer, IHostelContainer,
     7                              IFacultyContainer)
     8from waeup.viewlets import MainArea
    79
    810class University(grok.Application, grok.Container):
     11    """A university.
     12    """
    913    grok.implements(IUniversity)
    1014
     
    1216        super(University, self).__init__(**kw)
    1317        self.name = name
    14         app_setup.setup(self)
     18        self.setup()
    1519
     20    def setup(self):
     21        self["students"] = getUtility(IStudentContainer)
     22        self["hostels"] = getUtility(IHostelContainer)
     23        self["faculties"] = getUtility(IFacultyContainer)
     24       
     25class Manage(grok.EditForm):
     26    """Manage the basic properties of a `University` instance.
     27    """
     28
     29    grok.require('waeup.ManageUniversity')
     30   
     31    form_fields = grok.AutoFields(IUniversity)
     32
     33    @grok.action('Save')
     34    def save(self, **data):
     35        self.applyData(self.context, **data)
     36        return
     37   
     38    @grok.action('Save and return')
     39    def saveAndReturn(self, **data):
     40        self.applyData(self.context, **data)
     41        self.redirect(self.url(self.context))
     42        return
     43
     44    @grok.action('Cancel')
     45    def cancel(self):
     46        self.redirect(self.url(self.context))
     47        return
     48       
    1649class Content(grok.Viewlet):
    1750    grok.viewletmanager(MainArea)
Note: See TracChangeset for help on using the changeset viewer.