Changeset 200 for waeup_product/trunk/exportimport.py
- Timestamp:
- 10 May 2006, 06:58:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup_product/trunk/exportimport.py
r199 r200 1 # (C) Copyright 2006 Nuxeo SAS <http://nuxeo.com> 2 # Author: Olivier Grisel <ogrisel@nuxeo.com> 3 # 4 # This program is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License version 2 as published 6 # by the Free Software Foundation. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program; if not, write to the Free Software 15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 16 # 02111-1307, USA. 17 # 1 #-*- mode: python; mode: fold -*- 18 2 # $Id: exportimport.py 31640 2006-01-15 19:22:29Z ogrisel $ 19 3 """WAeUP Tool XML Adapter. … … 54 38 # WAeUP/profiles/default/ directory. 55 39 40 41 def setupStructure(context): ###( 42 sections = getattr(context,'sections') 43 portal = getattr(sections,'uniportal',None) 44 if portal is None: 45 sections.invokeFactory('University','uniportal') 46 portal = getattr(context,'uniportal',None) 47 portal.getContent().edit(mapping={'Title':SRPP_TITLE}) 48 students = getattr(portal,'students',None) 49 if students is None: 50 portal.invokeFactory('StudentsFolder','students') 51 students = getattr(portal,'students').getContent() 52 students.edit(mapping={'Title':'Students'}) 53 academics = getattr(portal,'academics',None) 54 if academics is None: 55 portal.invokeFactory('AcademicsFolder','academics') 56 academics = getattr(portal,'academics') 57 academics.getContent().edit(mapping={'Title':'Academics'}) 58 installFaculties(academics) 59 if not hasattr(portal,'accommodation'): 60 portal.invokeFactory('AccoFolder','accommodation') 61 accommodation = getattr(portal,'accommodation').getContent() 62 accommodation.edit(mapping={'Title':'Accommodation'}) 63 ###) 64 65 66 def installFaculties( academics): ###( 67 """install Universityspecific Faculies with Departments""" 68 faculties = [ 69 ## {'id': 'agri', ###( 70 ## 'Title': 'Agriculture', 71 ## 'departments': [ 72 ## { 'id': 'dep1', ###( 73 ## 'Title': 'One', 74 ## }, 75 ## ], 76 ## },###) 77 { 'id': 'science', 78 'Title': 'Science', 79 'departments': [ 80 { 'id': 'bio', ###( 81 'Title': 'Biochemistry', 82 }, 83 { 'id': 'bot', 84 'Title': 'Botany', 85 }, 86 { 'id': 'che', 87 'Title': 'Chemistry', 88 }, 89 { 'id': 'com', 90 'Title': 'Computer Science', 91 }, 92 { 'id': 'geo', 93 'Title': 'Geologie', 94 }, 95 { 'id': 'mat', 96 'Title': 'Mathematics', 97 }, 98 { 'id': 'mic', 99 'Title': 'Microbiology', 100 }, 101 { 'id': 'opt', 102 'Title': 'Optometry', 103 }, 104 { 'id': 'phy', 105 'Title': 'Physics', 106 }, 107 { 'id': 'zoo', 108 'Title': 'Zoology', 109 }, 110 ], 111 },###) 112 ]###) 113 for faculty in faculties: 114 fid = faculty['id'] 115 f = getattr(academics,fid,None) 116 if f is None: 117 #self.log('Creating Faculty %(id)s = %(Title)s' % faculty) 118 academics.invokeFactory('Faculty', fid) 119 f = getattr(academics,fid) 120 f.getContent().edit(mapping=faculty) 121 for department in faculty['departments']: 122 #self.log('Checking Department %(id)s = %(Title)s' % department) 123 did = department['id'] 124 d = getattr(f,did,None) 125 if d is None: 126 #self.log('Creating Department %(id)s = %(Title)s' % department) 127 f.invokeFactory('Department', did) 128 d = getattr(f,did) 129 d.getContent().edit(mapping=department) 130 ###) 131 132 56 133 def exportWAeUP(context): 57 134 """Export our WAeUP tool configuration … … 69 146 """ 70 147 site = context.getSite() 71 tool = getToolByName(site, TOOL) 72 importObjects(tool, '', context) 148 setupStructure(site) 149 pass 150 #site = context.getSite() 151 #tool = getToolByName(site, TOOL) 152 #importObjects(tool, '', context) 73 153 74 154 … … 79 159 class WAeUPXMLAdapter(XMLAdapterBase, PropertyManagerHelpers): 80 160 """XML importer and exporter for the WAeUP tool. 81 82 The vogon tool has very little persistent configuration to im- / export:83 only two properties that can be handled by the standard84 PropertyManagerHelpers methods.85 161 86 162 Hence this XMLAdapter is really simple. To get more complete examples of
Note: See TracChangeset for help on using the changeset viewer.