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

Last change on this file since 6640 was 6637, checked in by Henrik Bettermann, 14 years ago

Add logger, student workflow and student workflow history.

  • Property svn:keywords set to Id
File size: 2.4 KB
RevLine 
[6621]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
[6637]23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
24from waeup.sirp.interfaces import IObjectHistory
[6621]25from waeup.sirp.students.interfaces import IStudent
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)
33    grok.provides(IStudent)
34
35    def __init__(self):
36        super(Student, self).__init__()
[6637]37        IWorkflowInfo(self).fireTransition('create')
[6621]38        return
39
[6637]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
[6621]54# Set all attributes of Student required in IStudent as field
55# properties. Doing this, we do not have to set initial attributes
56# ourselves and as a bonus we get free validation when an attribute is
57# set.
58Student = attrs_to_fields(Student)
59
60class StudentFactory(grok.GlobalUtility):
61    """A factory for students.
62    """
63    grok.implements(IFactory)
64    grok.name(u'waeup.Student')
65    title = u"Create a new student.",
66    description = u"This factory instantiates new student instances."
67
68    def __call__(self, *args, **kw):
69        return Student()
70
71    def getInterfaces(self):
72        return implementedBy(Student)
Note: See TracBrowser for help on using the repository browser.