def importStructure(self, import_file):
     tree = ElementTree.parse(import_file)
     for community in tree.getiterator('community'):
         c_title = community.find('name').text
         c_id = slugify(c_title)
         c_desc = community.find('description').text
         
         # create the community
         if c_id not in self.context.objectIds():
             self.context.invokeFactory('RepositoryCommunity',
                                         c_id)
             comm_obj = self.context.get(c_id)
             setattr(comm_obj, 'title', c_title)
             setattr(comm_obj, 'description', c_desc)
             self.portal_workflow.doActionFor(comm_obj, 
             'publish')
             notify_init(comm_obj)
             comm_obj.reindexObject()
             
         # create collections
         for collection in community.getiterator('collection'):
             co_title = collection.find('name').text
             co_id = slugify(co_title)
             co_desc = collection.find('description').text
             parent_community = self.context.get(c_id, None)
             if parent_community:
                 if co_id not in parent_community.objectIds():
                     parent_community.\
                         invokeFactory('RepositoryCollection',
                         co_id)
                     collection_obj = parent_community.get(co_id)
                     setattr(collection_obj, 'title', co_title)
                     setattr(collection_obj, 'description', co_desc)
                     self.portal_workflow.doActionFor(collection_obj,
                     'publish')
                     notify_init(collection_obj)
                     collection_obj.reindexObject()
     return
Example #2
0
 def getCommunityAddress(self):
     if not self.mtool.isAnonymousUser():
         user = self.mtool.getAuthenticatedMember()
         country = user.getProperty("country", None)
         if country is not None:
             country_id = ''
             try:
                 term = country_vocabulary.getTerm(country)
                 country_id = slugify(term.title)
             except LookupError:
                 log.error
             if country_id in self.context.objectIds():
                 community = getattr(self.context_object, country_id)
                 return community.absolute_url()
     return self.context_object.absolute_url()
 def getCommunityAddress(self):
     if not self.mtool.isAnonymousUser():
         user = self.mtool.getAuthenticatedMember()
         country = user.getProperty("country", None)
         if country is not None:
             country_id = ''
             try:
                 term = country_vocabulary.getTerm(country)
                 country_id = slugify(term.title)
             except LookupError:
                 log.error
             if country_id in self.context.objectIds():
                 community = getattr(self.context_object, country_id)
                 return community.absolute_url()
     return self.context_object.absolute_url()
Example #4
0
    def importStructure(self, import_file):
        tree = ElementTree.parse(import_file)
        for community in tree.getiterator('community'):
            c_title = community.find('name').text
            c_id = slugify(c_title)
            c_desc = community.find('description').text

            # create the community
            if c_id not in self.context.objectIds():
                self.context.invokeFactory('RepositoryCommunity', c_id)
                comm_obj = self.context.get(c_id)
                setattr(comm_obj, 'title', c_title)
                setattr(comm_obj, 'description', c_desc)
                self.portal_workflow.doActionFor(comm_obj, 'publish')
                notify_init(comm_obj)
                comm_obj.reindexObject()

            # create collections
            for collection in community.getiterator('collection'):
                co_title = collection.find('name').text
                co_id = slugify(co_title)
                co_desc = collection.find('description').text
                parent_community = self.context.get(c_id, None)
                if parent_community:
                    if co_id not in parent_community.objectIds():
                        parent_community.\
                            invokeFactory('RepositoryCollection',
                            co_id)
                        collection_obj = parent_community.get(co_id)
                        setattr(collection_obj, 'title', co_title)
                        setattr(collection_obj, 'description', co_desc)
                        self.portal_workflow.doActionFor(
                            collection_obj, 'publish')
                        notify_init(collection_obj)
                        collection_obj.reindexObject()
        return