Changeset 3159 in products


Ignore:
Timestamp:
Apr 20, 2011 10:39:13 AM (13 years ago)
Author:
mylan
Message:

Prevent replacing existent objects on reinstallation package, updated comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ploneorg.kudobounty/trunk/ploneorg/kudobounty/setuphandlers.py

    r3158 r3159  
    4242            wftool.doActionFor(topic, 'publish') 
    4343         
    44         logger.info("Bounty submissions aggregator successfully added") 
    45  
     44        logger.info("Bounty submissions aggregator added") 
     45    else: 
     46        logger.info("Bounty submissions aggregator already exist at %s" % \ 
     47                    topic.absolute_url()) 
    4648 
    4749def createPFGForm(context, container, wftool, logger): 
     
    4951    """ 
    5052    form = getattr(container, FORM_ID, None) 
    51     if form is not None: 
    52         container.manage_delObjects(ids = FORM_ID) 
    53     # Create new form object 
    54     container.invokeFactory(id=FORM_ID, type_name="FormFolder", 
    55                            title="Bounty Submission Form") 
    56     form = getattr(container, FORM_ID) 
    57     # cleanup form and import data from the archive 
    58     form.manage_delObjects(ids=form.objectIds()) 
    59     pfg_data = context.readDataFile("submissions-form.tar.gz") 
    60     ctx = TarballImportContext(form, pfg_data) 
    61     IFilesystemImporter(form).import_(ctx, 'structure', True) 
    62     # Fix importing PFG via GS bug 
    63     #   - it adds extra indentation, wchich breaks the script. 
    64     create_bounty_script = form["create-bounty-submission"] 
    65     create_bounty_script.setScriptBody(CREATE_SCRIPT_BODY) 
    66     # Update and pubhish the form 
    67     form.update(**{"actionAdapter":["create-bounty-submission",],}) 
    68     form.unmarkCreationFlag() 
    69     form.reindexObject() 
    70     if wftool.getInfoFor(form, 'review_state') != 'published': 
    71         wftool.doActionFor(form, 'publish') 
    72     logger.info("Bounty submission form successfully created")  
     53    if form is None: 
     54        container.invokeFactory(id=FORM_ID, type_name="FormFolder", 
     55                               title="Bounty Submission Form") 
     56        form = getattr(container, FORM_ID) 
     57        # cleanup form and import data from the archive 
     58        form.manage_delObjects(ids=form.objectIds()) 
     59        pfg_data = context.readDataFile("submissions-form.tar.gz") 
     60        ctx = TarballImportContext(form, pfg_data) 
     61        IFilesystemImporter(form).import_(ctx, 'structure', True) 
     62        # Fix importing PFG via GS bug 
     63        #   - it adds extra indentation, wchich breaks the script. 
     64        create_bounty_script = form["create-bounty-submission"] 
     65        create_bounty_script.setScriptBody(CREATE_SCRIPT_BODY) 
     66        # Update and pubhish the form 
     67        form.update(**{"actionAdapter":["create-bounty-submission",],}) 
     68        form.unmarkCreationFlag() 
     69        form.reindexObject() 
     70        if wftool.getInfoFor(form, 'review_state') != 'published': 
     71            wftool.doActionFor(form, 'publish') 
     72        logger.info("Bounty submission form created")  
     73    else: 
     74        logger.info("Bounty submissions form already exist at %s" % \ 
     75                    form.absolute_url()) 
    7376 
    7477def createStructure(context, logger): 
     
    7780 
    7881    # CONTAINER 
    79     if  CONTAINER_ID not in site.objectIds(): 
     82    folder = getattr(site, CONTAINER_ID, None) 
     83    if  folder is None: 
    8084        _createObjectByType('Folder', site, id=CONTAINER_ID, 
    8185                            title=CONTAINER_TITLE) 
     
    9296 
    9397        logger.info("Submissions container added") 
     98    else: 
     99        logger.info("Submissions container already exist at %s" % \ 
     100                    folder.absolute_url()) 
    94101 
    95102    createTopic(folder, wftool, logger) 
Note: See TracChangeset for help on using the changeset viewer.