Changeset 139 for waeup_product/trunk/Extensions
- Timestamp:
- 2 Nov 2005, 14:40:07 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup_product/trunk/Extensions/install.py
r124 r139 1 1 #-*- mode: python; mode: fold -*- 2 2 # $Id$ 3 from Products.ExternalMethod.ExternalMethod import ExternalMethod 3 4 from Products.CPSInstaller.CPSInstaller import CPSInstaller 4 from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent 5 from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent,AccessContentsInformation 5 6 from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\ 6 7 DepartmentManage,CourseManage … … 18 19 from Products.WAeUP.Students import addStudentsFolder 19 20 21 SRPP_ID = "demouni" 22 SRPP_TITLE = "Demo University" 23 20 24 class WAeUPInstaller(CPSInstaller): 21 25 """ … … 26 30 def install(self,portal): 27 31 "install" 32 log = [] 33 prlog = log.append 34 35 def pr(msg, prlog=prlog): 36 prlog('%s<br>' % msg) 28 37 29 38 product_name = self.product_name 30 self.log("Starting %(product_name)s install" % vars() )39 pr("Starting %(product_name)s install" % vars() ) 31 40 32 41 # Roles and Permissions ###( … … 64 73 } 65 74 self.setupPortalPermissions(waeup_perms) 66 67 ###) 75 ###) 76 77 # external methods ###( 78 # 79 ext_methods = ( { 'id': 'waeup_migrate', 80 'title': 'WAeUP (migrate from an earlier version)', 81 'script': 'WAeUP.install', 82 'method': 'migrate', 83 'protected': 1, 84 }, 85 ) 86 portal_objectIds = portal.objectIds() 87 for meth in ext_methods: 88 method = meth['id'] 89 if method in portal_objectIds: 90 portal._delObject(method) 91 pr('Creating %s External Method' % method) 92 ext_method = ExternalMethod(method, 93 meth['title'], 94 meth['script'], 95 meth['method']) 96 portal._setObject(method, ext_method) 97 if method in portal_objectIds: 98 manage_perms = portal[method].manage_permission 99 if meth['protected']: 100 pr("Protecting %s" % method) 101 manage_perms(View, roles=['Manager'], acquire=0) 102 manage_perms(AccessContentsInformation, roles=['Manager'], acquire=0) 103 else: 104 manage_perms(View, roles=['Manager'], acquire=1) 105 ###) 68 106 69 107 ########################################## … … 142 180 # main_tab actions ###( 143 181 ########################################## 182 path = "/sections/%(SRPP_ID)s" % globals() 144 183 actions = ( { 'tool' : 'portal_actions', 145 184 'id' : 'student_administration', 146 185 'name' : 'Students', 147 'action' : 'string:$folder_url/students', 186 #'action' : 'string:$folder_url/students', 187 'action' : 'string:$portal_url%(path)s/students' % vars(), 148 188 'permission': (View, ), 149 189 'category' : 'main_tabs', … … 153 193 'id' : 'Academics', 154 194 'name' : 'Academics', 155 #'action' : 'string:${portal_url}/sections/waeup/academics/academics_view', 156 'action' : 'string:$folder_url/academics', 195 'action' : 'string:$portal_url%(path)s/academics' % vars(), 196 #'action' : 'string:${portal_url}/sections/unidemo', 197 #'action' : 'string:$folder_url/academics', 157 198 'permission': (View ), 158 199 'category' : 'main_tabs', … … 162 203 'id' : 'accomodation', 163 204 'name' : 'Accommodation', 205 'action' : 'string:$portal_url%(path)s/accommodation' % vars(), 164 206 #'action' : 'string:${portal_url}/sections/waeup/accommodation/accommodation_index_html', 165 'action' : 'string:$folder_url/accommodation',166 207 'permissions': (View), 167 208 #'permissions': (ModifyPortalContent,UniversityManage,StudentManage), … … 230 271 # skins 231 272 ########################################## 232 self.log("Verifying %(product_name)s skinss" % vars())273 pr("Verifying %(product_name)s skinss" % vars()) 233 274 wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', 234 275 'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty', … … 238 279 self.resetSkinCache() 239 280 281 # Themes ###( 282 # 283 # Importing portal themes 284 ## theme_container = getattr(portal, 'portal_themes') 285 ## # the first theme in each category is the default theme. 286 ## themes_list = {'WAeUP': ({'id': 'waeup_plain_theme', 287 ## 'file': 'waeup_plain_theme.zexp', 288 ## }, 289 ## {'id': 'waeup_management_theme', 290 ## 'file': 'waeup_management_theme.zexp', 291 ## }, 292 ## ), 293 ## } 294 ## 295 ## 296 ## theme_ids = theme_container.objectIds() 297 ## theme_container.manage_delObjects(theme_ids) 298 ## target_themes = themes_list[Target] 299 ## for theme in target_themes: 300 ## pr(" Importing %s theme" % theme['id']) 301 ## zexppath = os.path.join(zexpdir, theme['file']) 302 ## try: 303 ## theme_container._importObjectFromFile(zexppath) 304 ## except: 305 ## pr(" Could not import theme %s" % theme['id']) 306 ## 307 ## # set the first theme in the list as the default one. 308 ## theme_container.setDefaultTheme(target_themes[0]['id']) 309 ###) 310 311 240 312 ########################################## 241 313 # portal types … … 247 319 # Schemas 248 320 ########################################## 249 self.log("Verifying %(product_name)s schemas" % vars())321 pr("Verifying %(product_name)s schemas" % vars()) 250 322 self.verifySchemas(portal.getWAeUPSchemas()) 251 323 ########################################## 252 324 # widgets 253 325 ########################################## 254 self.log("Verifying %(product_name)s widgets" % vars())326 pr("Verifying %(product_name)s widgets" % vars()) 255 327 self.verifyWidgets(portal.getWAeUPWidgets()) 256 328 ########################################## 257 329 # layouts 258 330 ########################################## 259 self.log("Verifying %(product_name)s layouts" % vars())331 pr("Verifying %(product_name)s layouts" % vars()) 260 332 self.verifyLayouts(portal.getWAeUPLayouts()) 261 333 ########################################## 262 334 # Vocabularies 263 335 ########################################## 264 self.log("Verifying %(product_name)s vocabularies" % vars())336 pr("Verifying %(product_name)s vocabularies" % vars()) 265 337 self.verifyVocabularies(portal.getWAeUPVocabularies()) 266 338 ########################################## … … 271 343 self.verifyWorkflowAssociation() 272 344 273 self.log("End of specific %(product_name)s install" % vars()) 345 pr("End of specific %(product_name)s install" % vars()) 346 #return '\n'.join(log) 274 347 self.finalize() 275 348 … … 329 402 #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) 330 403 sections = getattr(self,'sections') 331 waeup = getattr(sections, 'waeup',None)404 waeup = getattr(sections,SRPP_ID,None) 332 405 if not waeup: 333 sections.content_create(type_name='University',title='waeup') 334 sections.waeup.folder_localrole_add(member_ids=('group:Students',), 406 sections.invokeFactory('University',SRPP_ID) 407 waeup = getattr(sections,SRPP_ID) 408 waeup.getContent().edit(mapping={'Title':SRPP_TITLE}) 409 waeup.folder_localrole_add(member_ids=('group:Students',), 335 410 member_role='SectionReviewer', 336 411 ) 337 sections.waeup.content_create(type_name='StudentsFolder',title='students') 338 sections.waeup.folder_localrole_add(member_ids=('group:Students',), 412 waeup.invokeFactory('StudentsFolder','students') 413 students = getattr(waeup,'students').getContent() 414 students.edit(mapping={'Title':'Students'}) 415 waeup.folder_localrole_add(member_ids=('group:Students',), 339 416 member_role='SectionReviewer', 340 417 ) 341 sections.waeup.content_create(type_name='AcademicsFolder',title='academics')418 ## waeup.content_create(type_name='AcademicsFolder',title='academics') 342 419 ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), 343 420 ## member_role='SectionManager', 344 421 ## ) 345 sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) 346 elif not hasattr(waeup,'academics'): 347 waeup.content_create(type_name='AcademicsFolder',title='academics') 348 sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) 422 waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) 423 waeup.invokeFactory('AcademicsFolder','academics', title='Academics') 424 academics = getattr(waeup,'academics').getContent() 425 academics.edit(mapping={'Title':'Academics'}) 426 waeup.invokeFactory('AccoFolder','accommodation', title='Accommodation') 427 accommodation = getattr(waeup,'accommodation').getContent() 428 accommodation.edit(mapping={'Title':'Accommodation'}) 429 if not hasattr(waeup,'academics'): 430 waeup.invokeFactory('AcademicsFolder','academics') 431 academics = getattr(waeup,'academics').getContent() 432 academics.edit(mapping={'Title':'Academics'}) 433 if not hasattr(waeup,'accommodation'): 434 waeup.invokeFactory('AccoFolder','accommodation') 435 accommodation = getattr(waeup,'accommodation').getContent() 436 accommodation.edit(mapping={'Title':'Accommodation'}) 437 waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) 349 438 # portlets ###( 350 439 # … … 395 484 396 485 return installer.logResult() 486 487 def migrate(self): 488 "update data" 489 log = [] 490 prlog = log.append 491 492 def pr(msg, prlog=prlog): 493 prlog('%s<br>' % msg) 494 495 sections = getattr(self,'sections') 496 waeup = getattr(sections,'waeup',None) 497 pr( "Start migrate") 498 pr("migrating courses") 499 for fac in [getattr(waeup,f.id) for f in waeup.contentValues(filter={'portal_type': ('Faculty',)})]: 500 pr("Faculty: %s" % fac.title_or_id()) 501 for dep in [getattr(fac,d.id) for d in fac.contentValues(filter={'portal_type': ('Department',)})]: 502 pr("Department: %s" % dep.title_or_id()) 503 for course in [getattr(dep,c.id) for c in dep.contentValues(filter={'portal_type': ('Course',)})]: 504 pr("Course: %s" % course.title_or_id()) 505 content = course.getContent() 506 heading = getattr(content,'heading',course.id) 507 pr("heading = %(heading)s" % vars()) 508 content.edit(mapping={'Title': heading}) 509 pr("migrating halls") 510 for ac in [getattr(waeup,a.id) for a in waeup.contentValues(filter={'portal_type': ('AccoFolder',)})]: 511 for hall in [getattr(ac,h.id) for h in ac.contentValues(filter={'portal_type': ('Accommodation',)})]: 512 pr("Hall: %s" % hall.title_or_id()) 513 content = hall.getContent() 514 heading = getattr(content,'heading',hall.id) 515 pr("heading = %(heading)s" % vars()) 516 content.edit(mapping={'Title': heading}) 517 return '\n'.join(log) 518
Note: See TracChangeset for help on using the changeset viewer.