source: waeup/branches/ulif-layout/src/waeup/app.py @ 4742

Last change on this file since 4742 was 4742, checked in by uli, 15 years ago

Start switch to make main University subcontainers like faculties,
usercontainers, etc. real folder items and not attributes.

This way we get some advantages out of the box:

  • Subitems are indexed automatically when we create an appropriate catalog.
  • Location settings (parent, name) are set automatically.
  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1import grok
2from zope.app.authentication.authentication import PluggableAuthentication
3from zope.app.security.interfaces import IAuthentication
4from zope.component import createObject
5
6from waeup.interfaces import IUniversity, ICSVDataReceivers
7from waeup.authentication import setup_authentication
8from waeup.datacenter import DataCenter
9from waeup.users import UserContainer
10
11class University(grok.Application, grok.Container):
12    """A university.
13    """
14    grok.implements(IUniversity, ICSVDataReceivers)
15    # Setup authentication for this app. Note: this is only
16    # initialized, when a new instance of this app is created.
17    grok.local_utility(
18        PluggableAuthentication, provides = IAuthentication,
19        setup = setup_authentication)
20   
21    def __init__(self, name=u'Sample University', **kw):
22        super(University, self).__init__(**kw)
23        self.name = name
24        self.setup()
25
26    def setup(self):
27        self.students = createObject(u'waeup.StudentContainer')
28        self.hostels = createObject(u'waeup.HostelContainer')
29        self.faculties = createObject(u'waeup.FacultyContainer')
30        # TODO: We need this to get URLs of subobjects. Can we avoid it?
31        self.faculties.__parent__ = self
32        self.faculties.__name__ = 'faculties'
33        self['users'] = UserContainer()
34        self['datacenter'] = DataCenter()
35 
36    def traverse(self, name):
37        # If someone requests a subobject 'faculties', we return our
38        # `faculties` attribute.
39        if name == 'faculties':
40            return self.faculties
41        elif name == 'hostels':
42            return self.hostels
43        elif name == 'students':
44            return self.students
45        elif name == 'users':
46            return self['users']
47        elif name == 'datacenter':
48            return self['datacenter']
49        return None
Note: See TracBrowser for help on using the repository browser.