| | 41 | |
| | 42 | #this is a superflous function, guarateened to introduce bugs |
| | 43 | #but the install process is hideous |
| | 44 | #anyway, copied from PlumiSkin (called there installUser) |
| | 45 | def reinstallEngageMediaUser(self,out): |
| | 46 | """We create a user for EngageMedia |
| | 47 | It will first try to delete the user with the same id |
| | 48 | and then register a new one with all the infos. |
| | 49 | Read config.py for more informations |
| | 50 | """ |
| | 51 | mt = getToolByName(self,'portal_membership') |
| | 52 | # If you are going to have an installed password, at least make it pseduo-random |
| | 53 | password = md5.md5(str(time.time())).hexdigest()[:12] |
| | 54 | |
| | 55 | if mt.getMemberById(USER['id']) is None: |
| | 56 | mt.addMember(USER['id'], password, ['Member','Manager'], []) |
| | 57 | member = mt.getMemberById(USER['id']) |
| | 58 | member.setMemberProperties({'fullname': USER['fullname'], |
| | 59 | 'email': USER['email'], |
| | 60 | 'last_login_time': DateTime('2006-06-01'),}) |
| | 61 | |
| | 62 | #We need to reclaim 'latestvideos' 'news' 'events' 'featured-videos' 'news_and_events' |
| | 63 | # |
| | 64 | items = ['latestvideos', 'news', 'events', 'featured-videos', 'news_and_events'] |
| | 65 | for i in items: |
| | 66 | obj = getattr(self,i,None) |
| | 67 | if obj is not None: |
| | 68 | publishObjectandOwnership(self,obj,USER['id']) |
| | 69 | |
| | 70 | # Checks for Taxonomy objects installed by ATVideo (ATEngageVideo) |
| | 71 | # take ownership of them by the Plumi user, update layouts |
| | 72 | # |
| | 73 | from Products.ATVideo.config import GENRE_FOLDER, CATEGORIES_FOLDER, COUNTRIES_FOLDER, SUBMISSIONS_FOLDER, TOPLEVEL_FOLDER |
| | 74 | from zLOG import LOG, INFO |
| | 75 | |
| | 76 | #thats to remind us of this evil we face |
| | 77 | if hasattr(self,TOPLEVEL_FOLDER): |
| | 78 | out.write('Changing ownership of taxonomy folder and sub-folders!\n') |
| | 79 | toplvl_fldr = getattr(self,TOPLEVEL_FOLDER) |
| | 80 | publishObjectandOwnership(self, toplvl_fldr ,USER['id']) |
| | 81 | idstochange = [ GENRE_FOLDER, CATEGORIES_FOLDER, COUNTRIES_FOLDER, SUBMISSIONS_FOLDER ] |
| | 82 | for x in idstochange: |
| | 83 | obj = getattr(toplvl_fldr,x,None) |
| | 84 | if obj is not None: |
| | 85 | LOG('EngagePlumiSkin Installer',INFO,' about to change %s ' % obj.Title()) |
| | 86 | #change ownership of smart folder |
| | 87 | publishObjectandOwnership(self,obj,USER['id']) |
| | 88 | #update the children objects too |
| | 89 | ids_to_update = [ sub_obj for sub_obj in obj.objectIds() ] |
| | 90 | for y in ids_to_update: |
| | 91 | sub_obj = getattr(obj,y) |
| | 92 | LOG('EngagePlumiSkin Installer',INFO,' about to change %s ' % sub_obj.Title()) |
| | 93 | publishObjectandOwnership(self,sub_obj,USER['id']) |
| | 94 | #update the layout |
| | 95 | sub_obj.setLayout('video_listing_view') |
| | 96 | else: |
| | 97 | out.write('No top level taxonomy folder found!\n') |
| | 98 | |
| | 99 | #This is copied from PlumiSkin also |
| | 100 | def publishObjectandOwnership(self, obj,user_id): |
| | 101 | """This method sets the given user as creator of the |
| | 102 | given object. Then, it tries to trigger the workflow |
| | 103 | transition to publish it. |
| | 104 | """ |
| | 105 | obj.setCreators(user_id) |
| | 106 | self.plone_utils.changeOwnershipOf(obj, user_id, 1) |
| | 107 | |
| | 108 | try: |
| | 109 | # Try to publish it straight away |
| | 110 | workflow = getToolByName(self,'portal_workflow') |
| | 111 | workflow.doActionFor(obj, 'publish') |
| | 112 | except WorkflowException: |
| | 113 | pass |
| | 114 | |
| | 115 | |