#-*- mode: python; mode: fold -*- from Globals import InitializeClass from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import UniqueObject, getToolByName from Products.CMFCore.permissions import View from Products.CMFCore.permissions import ModifyPortalContent from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument from Products.CPSDocument.CPSDocument import CPSDocument from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder class StudentsFolder(BaseBTreeFolder): ###( """ WAeUP container for the various WAeUP containers data """ meta_type = 'Students Folder' portal_type = meta_type security = ClassSecurityInfo() security.declarePublic("doCheckAdmission") def doCheckAdmission(self,type_name,datamodel): "the admission callback" ## class CPSUnrestrictedUser(UnrestrictedUser): ## """Unrestricted user that still has an id. ## ## Taken from CPSMembershipTool ## """ ## ## def getId(self): ## """Return the ID of the user.""" ## return self.getUserName() print type_name print datamodel return self.REQUEST.RESPONSE.redirect("%s" % self.absolute_url()) mtool = getToolByName(self, 'portal_membership') username = "%s" % datamodel.get('reg_nr') print username member=mtool.getMemberById("S%s" % username) print member from AccessControl.SecurityManagement import newSecurityManager newSecurityManager(None,member.__of__(mtool.acl_users)) # datamodel is passed so that flexti can initialize the object. #datamodel.set('lastname','Meier') student = getattr(self,username) student.invokeFactory('StudentPersonal', '%s' % username) ob = getattr(student, id) ##context.notifyCPSDocumentCreation(ob=ob) return ob InitializeClass(StudentsFolder) def addStudentsFolder(container, id, REQUEST=None, **kw): """Add a Student.""" ob = StudentsFolder(id, **kw) return CPSBase_adder(container, ob, REQUEST=REQUEST) ### ###) student_fti = { ###( 'title': 'WAeUP Student', 'description': '', 'content_icon': 'student.gif', 'content_meta_type': 'Student', 'factory': 'addStudent', 'immediate_view': 'cpsdocument_view', 'global_allow': True, 'filter_content_types': True, 'allowed_content_types': ('Jamb','StudentPersonal'), 'allow_discussion': False, 'actions': ( {'id': 'view', 'name': 'action_view', 'action': 'string:${object_url}/student_index_html', #'action': 'string:${object_url}/cpsdocument_view', 'condition': '', 'permission': ('View',), 'category': 'object', 'visible': True,}, {'id': 'new_content', 'name': 'Add Data', 'action': 'string:${object_url}/folder_factories', 'condition': "python:1 or len(object.contentItems()) == 0 ", 'permission': ('Modify portal content',), 'category': 'object', 'visible': True,}, {'id': 'contents', 'name': 'action_folder_contents', 'action': 'string:${object_url}/folder_contents', 'condition': "python:1 or object.getTypeInfo().cps_proxy_type != 'document'", 'permission': ('Modify portal content',), 'category': 'object', 'visible': True,}, {'id': 'edit', 'name': 'action_edit', 'action': 'string:${object_url}/cpsdocument_edit_form', 'condition': '', 'permission': ('Modify portal content',), 'category': 'object', 'visible': True,}, ) } ###) class Student(CPSDocument): ###( """ WAeUP Student container for the various student data """ meta_type = 'Student' portal_type = meta_type security = ClassSecurityInfo() security.declarePublic("test") def test(self): """test""" return self.REQUEST InitializeClass(Student) def addStudent(container, id, REQUEST=None, **kw): """Add a Student.""" ob = Student(id, **kw) return CPSBase_adder(container, ob, REQUEST=REQUEST) ###)