Changeset 1604 in products


Ignore:
Timestamp:
Jan 29, 2010 12:47:24 PM (14 years ago)
Author:
mylan
Message:

Updated constructor section for possibility to construct not only CMF objects, registered in fti

Location:
quintagroup.transmogrifier/branches/ofs/quintagroup/transmogrifier
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.transmogrifier/branches/ofs/quintagroup/transmogrifier/configure.zcml

    r1602 r1604  
    137137 
    138138    <utility 
     139        component=".constructor.ConstructorSection" 
     140        name="quintagroup.transmogrifier.extendedconstructor" 
     141        /> 
     142 
     143    <utility 
    139144        component=".ofsmanager.OFSExporterSection" 
    140145        name="quintagroup.transmogrifier.ofsexporter" 
    141146        /> 
     147 
     148    <utility 
     149        component=".utilities.FileFTIUtility" 
     150        provides=".interfaces.IFTIConstructor4MetaType" 
     151        name="File" 
     152        /> 
     153 
     154    <utility 
     155        component=".utilities.ImageFTIUtility" 
     156        provides=".interfaces.IFTIConstructor4MetaType" 
     157        name="Image" 
     158        /> 
     159 
    142160 
    143161    <adapter factory=".portlets.PortletAssignmentExportImportHandler" /> 
  • quintagroup.transmogrifier/branches/ofs/quintagroup/transmogrifier/constructor.py

    r1598 r1604  
    11from zope.interface import classProvides, implements 
     2from zope.component import queryUtility 
    23from collective.transmogrifier.interfaces import ISectionBlueprint 
    34from collective.transmogrifier.interfaces import ISection 
     
    67from Acquisition import aq_base 
    78from Products.CMFCore.utils import getToolByName 
     9 
     10from quintagroup.transmogrifier.interfaces import IFTIConstructor4MetaType 
    811 
    912class ConstructorSection(object): 
     
    1922                                      ('portal_type', 'Type')) 
    2023        self.pathkey = defaultMatcher(options, 'path-key', name, 'path') 
     24        self.meta_types = filter(None, [i.strip() for i in 
     25                                         options.get('meta-types', '').splitlines()]) 
    2126     
    2227    def __iter__(self): 
     
    3338            fti = self.ttool.getTypeInfo(type_) 
    3439            if fti is None:                           # not an existing type 
    35                 yield item; continue 
    36              
     40                # Look for an IFTIConstructor4MetaType adapter 
     41                mt = type_.startswith("meta_type:") and type_[10:] or None 
     42                if mt in self.meta_types: 
     43                    fti = queryUtility(IFTIConstructor4MetaType, name=mt) 
     44                if fti is None: 
     45                    yield item; continue 
     46 
    3747            elems = path.strip('/').rsplit('/', 1) 
    3848            container, id = (len(elems) == 1 and ('', elems[0]) or elems) 
     
    4050            if context is None:                       # container doesn't exist 
    4151                yield item; continue 
    42              
     52 
    4353            if getattr(aq_base(context), id, None) is not None: # item exists 
    4454                yield item; continue 
    45              
     55 
    4656            obj = fti._constructInstance(context, id) 
    4757            obj = fti._finishConstruction(obj) 
    4858            if obj.getId() != id: 
    4959                item[pathkey] = '%s/%s' % (container, obj.getId()) 
    50              
     60 
    5161            yield item 
  • quintagroup.transmogrifier/branches/ofs/quintagroup/transmogrifier/import.cfg

    r1568 r1604  
    2323.interfaces.xml = interfaces 
    2424.portlets.xml = portlets 
     25.file-properties.xml = file-properties 
    2526 
    2627[manifestimporter] 
     
    2829 
    2930[constructor] 
    30 blueprint = collective.transmogrifier.sections.constructor 
     31blueprint = quintagroup.transmogrifier.extendedconstructor 
    3132 
    3233[datacorrector] 
  • quintagroup.transmogrifier/branches/ofs/quintagroup/transmogrifier/interfaces.py

    r277 r1604  
    1616        """ Correct data given in 'data' argument and return it. 
    1717        """ 
     18 
     19class IFTIConstructor4MetaType(Interface): 
     20    """FTI utility analogy for constuct instance for not CMF objects""" 
     21 
     22    def _constructInstance(self, container, id, *args, **kw): 
     23        """Build a bare instance of the appropriate type. 
     24        Does not do any security checks. 
     25        Returns the object without calling _finishConstruction(). 
     26        """ 
     27 
     28    def _finishConstruction(obj): 
     29        """Finish the construction of a content object. 
     30        Set its portal_type, insert it into the workflows. 
     31        """ 
Note: See TracChangeset for help on using the changeset viewer.