Ignore:
Timestamp:
Aug 13, 2009 2:48:22 PM (10 years ago)
Author:
koval
Message:

manifest datacorrector for Blog content type now chekcs for existance of folder with images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.transmogrifier.simpleblog2quills/trunk/quintagroup/transmogrifier/simpleblog2quills/adapters.py

    r1193 r1241  
    2323SITE_URLS = [] 
    2424IMAGE_FOLDER = 'images' 
     25IMAGE_FOLDER_TYPE = 'Large Plone Folder' 
    2526# this registries are needed to avoid loosing images with equal ids 
    2627IMAGE_IDS = [] 
     
    3435 
    3536    def __call__(self, data): 
     37        # flag that indicated whether 'images' folder must added to manifest 
     38        need_to_add = True 
     39 
    3640        doc = minidom.parseString(data['data']) 
    3741        root = doc.documentElement 
     
    3943            if child.getAttribute('type') not in  ('BlogEntry', 'BlogFolder'): 
    4044                root.removeChild(child) 
    41         folder = doc.createElement('record') 
    42         folder.setAttribute('type', 'Large Plone Folder') 
    43         folder.appendChild(doc.createTextNode(IMAGE_FOLDER)) 
    44         root.appendChild(folder) 
     45            elif str(child.firstChild.nodeValue.strip()) == IMAGE_FOLDER: 
     46                # blog already contains object with IMAGE_FOLDER id 
     47                need_to_add = False 
     48 
     49        if need_to_add: 
     50            folder = doc.createElement('record') 
     51            folder.setAttribute('type', IMAGE_FOLDER_TYPE) 
     52            folder.appendChild(doc.createTextNode(IMAGE_FOLDER)) 
     53            root.appendChild(folder) 
     54 
    4555        data['data'] = doc.toxml('utf-8') 
    4656        return data 
Note: See TracChangeset for help on using the changeset viewer.