source: main/waeup.sirp/trunk/src/waeup/sirp/students/student.py @ 6642

Last change on this file since 6642 was 6642, checked in by Henrik Bettermann, 13 years ago

Add viewlet manager 'StudentSitebar?' which is rendered in a block above the LeftSidebar? viewlet manager block. This viewlet manager replaces the plain action buttons recently implemented.

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
2## This program is free software; you can redistribute it and/or modify
3## it under the terms of the GNU General Public License as published by
4## the Free Software Foundation; either version 2 of the License, or
5## (at your option) any later version.
6##
7## This program is distributed in the hope that it will be useful,
8## but WITHOUT ANY WARRANTY; without even the implied warranty of
9## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10## GNU General Public License for more details.
11##
12## You should have received a copy of the GNU General Public License
13## along with this program; if not, write to the Free Software
14## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15##
16"""
17Container for the various objects owned by students.
18"""
19import grok
20from grok import index
21from zope.component.interfaces import IFactory
22from zope.interface import implementedBy
23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
24from waeup.sirp.interfaces import IObjectHistory
25from waeup.sirp.students.interfaces import IStudent, IStudentNavigation
26from waeup.sirp.utils.helpers import attrs_to_fields
27
28class Student(grok.Container):
29    """This is a student container for the various objects
30    owned by students.
31    """
32    grok.implements(IStudent, IStudentNavigation)
33    grok.provides(IStudent)
34
35    def __init__(self):
36        super(Student, self).__init__()
37        IWorkflowInfo(self).fireTransition('create')
38        return
39
40    def loggerInfo(self, ob_class, comment=None):
41        target = self.__name__
42        return grok.getSite()['students'].logger_info(ob_class,target,comment)
43
44    @property
45    def state(self):
46        state = IWorkflowState(self).getState()
47        return state
48
49    @property
50    def history(self):
51        history = IObjectHistory(self)
52        return history
53
54    def getStudent(self):
55        return self
56
57# Set all attributes of Student required in IStudent as field
58# properties. Doing this, we do not have to set initial attributes
59# ourselves and as a bonus we get free validation when an attribute is
60# set.
61Student = attrs_to_fields(Student)
62
63class StudentFactory(grok.GlobalUtility):
64    """A factory for students.
65    """
66    grok.implements(IFactory)
67    grok.name(u'waeup.Student')
68    title = u"Create a new student.",
69    description = u"This factory instantiates new student instances."
70
71    def __call__(self, *args, **kw):
72        return Student()
73
74    def getInterfaces(self):
75        return implementedBy(Student)
Note: See TracBrowser for help on using the repository browser.