Changeset 1250 in products


Ignore:
Timestamp:
Aug 18, 2009 4:09:29 PM (15 years ago)
Author:
koval
Message:

fixed moving of blog entry contents, added script for getting exported content stats

Location:
quintagroup.transmogrifier.simpleblog2quills/branches/without_image_move/quintagroup/transmogrifier/simpleblog2quills
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.transmogrifier.simpleblog2quills/branches/without_image_move/quintagroup/transmogrifier/simpleblog2quills/cleaner.py

    r1249 r1250  
    55from collective.transmogrifier.interfaces import ISection 
    66 
    7 from Acquisition import aq_inner, aq_parent 
     7from zExceptions import BadRequest 
     8from Acquisition import aq_inner, aq_parent, aq_base 
    89from Products.CMFCore import utils 
    910 
     
    3031        """ 
    3132        entry = aq_inner(entry) 
    32         ids = entry.contentValues() 
     33        ids = entry.contentIds() 
     34        parent = aq_parent(entry) 
    3335 
    34         log.info('Moving from %s BlogEntry next object: %s' % (entry.getId(), ids)) 
    35         copy_data = entry.manage_cutObjects(ids) 
    36         parent = aq_parent(entry) 
    37         # xxx: next method call raises exception 
    38         parent.manage_pasteObjects(copy_data) 
     36        log.info('Moving from %s BlogEntry next objects: %s' % ('/'.join(entry.getPhysicalPath()), ids)) 
     37        for obj_id in ids: 
     38            obj = entry._getOb(obj_id) 
     39            entry._delObject(obj_id, suppress_events=True) 
     40            obj = aq_base(obj) 
     41            new_id = self.generateId(parent, obj_id) 
     42            if new_id != obj_id: 
     43                log.info('Changing id from %s to %s' % (obj_id, new_id)) 
     44                obj._setId(new_id) 
     45            try: 
     46                parent._setObject(new_id, obj, set_owner=0, suppress_events=True) 
     47            except BadRequest, e: 
     48                log.error(e) 
     49 
     50    def generateId(self, folder, id_): 
     51        c = 1 
     52        existing = folder.objectIds() 
     53        new_id = id_ 
     54        while True: 
     55            if id_ in existing: 
     56                id_ = new_id + str(c) 
     57                c += 1 
     58            else: 
     59                return new_id 
    3960 
    4061    def getNotEmptyEntries(self): 
  • quintagroup.transmogrifier.simpleblog2quills/branches/without_image_move/quintagroup/transmogrifier/simpleblog2quills/export.cfg

    r1249 r1250  
    11[transmogrifier] 
    22pipeline = 
    3 #    blogentrycleaner 
     3    blogentrycleaner 
    44    sitewalker 
    55    condition 
     
    1414    EXPORTING 
    1515 
    16 # this section isn't ready 
    1716[blogentrycleaner] 
    1817blueprint = quintagroup.transmogrifier.simpleblog2quills.blogentrycleaner 
     
    3635[propertiesexporter] 
    3736blueprint = quintagroup.transmogrifier.propertiesexporter 
    38 exclude = title 
     37exclude =  
     38    title 
     39    layout 
    3940 
    4041[commentsexporter] 
Note: See TracChangeset for help on using the changeset viewer.