コード例 #1
0
 def setupTypes(self, p, initial_types=factory_type_information):
     tool = getToolByName(p, 'portal_types', None)
     if tool is None:
         return
     for t in initial_types:
         fti = FactoryTypeInformation(**t)
         tool._setObject(t['id'], fti)
コード例 #2
0
    def _initSite(self, foo=0):
        self.root.site = Folder(id='site')
        site = self.root.site
        ttool = site.portal_types = TypesTool()

        if foo == 1:
            fti = _TI_LIST[0].copy()
            ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
            sti = _TI_LIST[1].copy()
            ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
        elif foo == 2:
            fti = _TI_LIST_WITH_FILENAME[0].copy()
            ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
            sti = _TI_LIST_WITH_FILENAME[1].copy()
            ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))

        return site
コード例 #3
0
    def _initSite(self, foo=0):
        site = Folder(id='site').__of__(self.app)
        ttool = TypesTool()
        getSiteManager().registerUtility(ttool, ITypesTool)

        if foo == 1:
            fti = _TI_LIST[0].copy()
            ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
            sti = _TI_LIST[1].copy()
            ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
        elif foo == 2:
            fti = _TI_LIST_WITH_FILENAME[0].copy()
            ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
            sti = _TI_LIST_WITH_FILENAME[1].copy()
            ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))

        return site, ttool
コード例 #4
0
    def setUp(self):
        import Products.CMFCore
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        BodyAdapterTestCase.setUp(self)
        zcml.load_config('configure.zcml', Products.CMFCore)

        self._obj = FactoryTypeInformation('foo_fti')
        self._BODY = _FTI_BODY
コード例 #5
0
ファイル: test_typeinfo.py プロジェクト: bendavis78/zope
    def setUp(self):
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        PlacelessSetup.setUp(self)
        zcml.load_config('meta.zcml', Products.Five)
        zcml.load_config('configure.zcml', Products.CMFCore.exportimport)

        self._obj = FactoryTypeInformation('foo_fti')
        self._XML = _FTI_XML
コード例 #6
0
ファイル: test_typeinfo.py プロジェクト: bendavis78/zope
    def getTypeInfo(self, id):

        info = [x for x in self._type_infos if x['id'] == id]
        if len(info) == 0:
            raise KeyError, id
        info = info[0]

        if 'product' in info.keys():
            return FactoryTypeInformation(**info)
        else:
            return ScriptableTypeInformation(**info)
コード例 #7
0
    def test_additive_prop(self):
        """ This tests the additive property of the import function.
            When you make local changes, the import function should
            only add and not replace things
        """
        # We first make some custom Composite Pack modifications
        self.ct.registerLayout("custom_layout_id", "custom_layout_title",
                               "custom_layout_skin_method")
        self.ct.registerViewlet("custom_viewlet_id", "custom_viewlet_title",
                                "custom_viewlet_skin_method")
        viewlet = self.ct.getViewletById("custom_viewlet_id")
        self.ct.registerViewletForType(viewlet, "custom_composable_id")
        layout = self.ct.getLayoutById("custom_layout_id")
        self.ct.registerLayoutForType(layout, "custom_composite_id")

        typetool = getToolByName(self.ct, 'portal_types')
        from Products.CMFCore.TypesTool import FactoryTypeInformation
        fti = FactoryTypeInformation(id="custom_composable_id")
        typetool._setObject(fti.id, fti)

        # Now we use Generic Setup to import the default
        self.gs.runAllImportStepsFromProfile(
            'profile-Products.CompositePack:default')

        # Let's get the Layouts
        layouts = self.ct.getAllLayouts()
        layouts_names = [str(l) for l in layouts]

        layouts_for_custom = self.ct.getRegisteredLayoutsForType(
            "custom_composite_id")
        layouts_for_custom_names = [str(lf) for lf in layouts_for_custom]

        # And let's get the Viewlets
        viewlets = self.ct.getAllViewlets()
        viewlets_names = [str(v) for v in viewlets]

        viewlets_for_custom = self.ct.getRegisteredViewletsForType(
            "custom_composable_id")
        viewlets_for_custom_names = [str(lv) for lv in viewlets_for_custom]

        # Now, let us check if our customization still exists or if the import
        # replaced it all.
        self.failUnless('<Layout at custom_layout_id>' in layouts_names,
                        "Custom layout was overwritten at import")
        self.failUnless('<Viewlet at custom_viewlet_id>' in viewlets_names,
                        "Custom viewlet was overwritten at import")
        self.failUnless(
            '<Viewlet at custom_viewlet_id>' in viewlets_for_custom_names,
            "Custom viewlet for composable overwritten at import")
        self.failUnless(
            '<Layout at custom_layout_id>' in layouts_for_custom_names,
            "Custom layout for composite overwritten at import")
コード例 #8
0
    def _populate(self, obj):
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        obj._setObject('foo_type', FactoryTypeInformation('foo_type'))
コード例 #9
0
    def _makeInstance(self, id, **kw):
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        return FactoryTypeInformation(id, **kw)
コード例 #10
0
 def _populate(self, obj):
     obj._setObject('foo_type', FactoryTypeInformation('foo_type'))
コード例 #11
0
 def setUp(self):
     self._obj = FactoryTypeInformation('foo_fti')
     self._BODY = _FTI_BODY
コード例 #12
0
 def setUp(self):
     self._obj = FactoryTypeInformation('foo_fti')
     self._BODY = _FTI_BODY
     self._trap_warning_output()
コード例 #13
0
ファイル: test_typeinfo.py プロジェクト: bendavis78/zope
    def setUp(self):
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        BodyAdapterTestCase.setUp(self)
        self._obj = FactoryTypeInformation('foo_fti')
        self._BODY = _FTI_BODY
コード例 #14
0
    __roles__ = ( 'FooAdder', )
    __allow_access_to_unprotected_subobjects__ = { 'addFoo' : 1 }


class DummyTypeInfo(TypeInformation):
    """ Dummy class of type info object """
    meta_type = "Dummy Test Type Info"

DummyFTI = FactoryTypeInformation( 'Dummy',
                                   meta_type=DummyContent.meta_type,
                                   product='CMFDefault',
                                   factory='addDocument',
                                   actions= ( { 'name'          : 'View',
                                                'action'        : 'view',
                                                'permissions'   : ('View', ) },
                                              { 'name'          : 'View2',
                                                'action'        : 'view2',
                                                'permissions'   : ('View', ) },
                                              { 'name'          : 'Edit',
                                                'action'        : 'edit',
                                                'permissions'   : ('forbidden permission',)
                                                }
                                              )
                                   )

class DummyFolder( Implicit ):
    """
        Dummy Container for testing
    """
    def __init__( self, fake_product=0, prefix='' ):
        self._prefix = prefix
コード例 #15
0
ファイル: test_typeinfo.py プロジェクト: bendavis78/zope
 def setUp(self):
     BodyAdapterTestCase.setUp(self)
     self._obj = FactoryTypeInformation('foo_fti')
     self._BODY = _FTI_BODY
コード例 #16
0
def update_discussion( self, split=string.split ):
    """
     1. Install (if it isn't there already) a type information
        object for DiscussionItems, so that they can get actions,
        etc.  Erase the "(default)" workflow bound to it, to prevent
        showing the "Retract" options, etc.

     2. Update all DiscussionItems to use the new marking for
        'in_reply_to':

          - Items which are replies to the containing content object
            have None as their 'in_reply_to';

          - Items which are replies to sibling items have the sibling's
            ID as their 'in_reply_to'.

        The representation we are converting from was:

          - Items which are replies to the containing content object
            have the portal-relative pathstring of the content object
            as their 'in_reply_to';

          - Items which are replies to sibling items have the absolute
            path of the sibling as their 'in_reply_to'.
    """

    log = []
    a = log.append
    types_tool = self.portal_types
    if not getattr( types_tool, 'Discussion Item', None ):

        fti = FactoryTypeInformation(**DiscussionItem.factory_type_information[0])

        types_tool._setObject( 'Discussion Item', fti )
        a( 'Added type object for DiscussionItem' )

        workflow_tool = self.portal_workflow
        workflow_tool.setChainForPortalTypes( ( 'Discussion Item', ), () )
        a( 'Erased workflow for DiscussionItem' )

    items = self.portal_catalog.searchResults( meta_type='Discussion Item' )
    a( 'DiscussionItems updated:' )

    for item in items:

        object = item.getObject()
        talkback = object.aq_parent
        path = item.getPath()
        in_reply_to = object.in_reply_to

        if in_reply_to is None: # we've been here already
            continue

        irt_elements = split( in_reply_to, '/' )

        if len( irt_elements ) == 1:
            if talkback._container.get( irt_elements[0] ):
                # we've been here already
                continue

        if irt_elements[0] == '': # absolute, so we are IRT a sibling
            sibling_id = irt_elements[ -1 ]
            if talkback._container.get( sibling_id, None ):
                in_reply_to = sibling_id
            else:
                in_reply_to = None
        else:
            in_reply_to = None

        object.in_reply_to = in_reply_to
        assert object.inReplyTo() # sanity check
        object.reindexObject()

        a( path )

    return string.join( log, '\n' )