コード例 #1
0
ファイル: DocumentBank.py プロジェクト: ksiktforum/ksiktforum
 def __init__(self, id, **kw):
     self._topictype = aq_base(kw['topic'])
     kw['actions'] = self._actions
     kw['aliases'] = self._aliases
     FactoryTypeInformation.__init__(self, id, **kw)
     self.product = ''
     self.factory = 'ksiktforum.documentbank'
     self.content_meta_type = 'Topic'
     self.content_icon = 'topic_icon.png'
     self.immediate_view = 'documentbank_view'
     self.title = 'documentbank'
     self.description = 'Specialized topic that can organize content under self chose labels'
コード例 #2
0
ファイル: WorkArea.py プロジェクト: ksiktforum/ksiktforum
 def __init__(self, id, **kw):
     self._topictype = aq_base(kw['topic'])
     kw['actions'] = self._actions
     kw['aliases'] = self._aliases
     FactoryTypeInformation.__init__(self, id, **kw)
     self.product = ''
     self.factory = 'ksiktforum.workarea'
     self.content_meta_type = 'Topic'
     self.content_icon = 'topic_icon.png'
     self.immediate_view = 'workarea_view'
     self.title = 'workarea'
     self.description = 'Specialized topic that handles access control'
コード例 #3
0
ファイル: fti.py プロジェクト: nacho22martin/tesis
 def manage_changeProperties(self, **kw):
     """Overwrite change properties to verify that default_view is in the method
     list
     """
     FactoryTypeInformation.manage_changeProperties(self, **kw)
     default_view = self.default_view
     view_methods = self.view_methods
     if not default_view:
         # TODO: use view action
         self.default_view = default_view = self.immediate_view
     if not view_methods:
         self.view_methods = view_methods = (default_view,)
     if default_view and default_view not in view_methods:
         raise ValueError, "%s not in %s" % (default_view, view_methods)
コード例 #4
0
 def manage_changeProperties(self, **kw):
     """Overwrite change properties to verify that default_view is in the method
     list
     """
     FactoryTypeInformation.manage_changeProperties(self, **kw)
     default_view = self.default_view
     view_methods = self.view_methods
     if not default_view:
         # TODO: use view action
         self.default_view = default_view = self.immediate_view
     if not view_methods:
         self.view_methods = view_methods = (default_view, )
     if default_view and default_view not in view_methods:
         raise ValueError("%s not in %s" % (default_view, view_methods))
コード例 #5
0
ファイル: fti.py プロジェクト: nacho22martin/tesis
    def queryMethodID(self, alias, default=None, context=None):
        """ Query method ID by alias.

        Use "(dynamic view)" as the alias target to look up as per defaultView()
        Use "(selected layout)" as the alias target to look up as per
            getViewMethod()
        """
        methodTarget = FactoryTypeInformation.queryMethodID(self, alias,
                                                         default=default,
                                                         context=context)
        if not isinstance(methodTarget, basestring):
            # nothing to do, method_id is probably None
            return methodTarget

        if context is None or default == '':
            # the edit zpts like typesAliases don't apply a context and set the
            # default to ''. We do not want to resolve (dynamic view) for these
            # methods.
            return methodTarget

        # Our two special targets:

        if methodTarget.lower() == "(dynamic view)":
            methodTarget = self.defaultView(context)

        if methodTarget.lower() == "(selected layout)":
            fallback = self.default_view_fallback
            methodTarget = self.getViewMethod(context, check_exists=fallback)

        return methodTarget
コード例 #6
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)
コード例 #7
0
    def queryMethodID(self, alias, default=None, context=None):
        # Query method ID by alias.

        # Use "(dynamic view)" as the alias target to look up as per
        # defaultView()

        # Use "(selected layout)" as the alias target to look up as per
        # getViewMethod()

        methodTarget = FactoryTypeInformation.queryMethodID(self,
                                                            alias,
                                                            default=default,
                                                            context=context)
        if not isinstance(methodTarget, str):
            # nothing to do, method_id is probably None
            return methodTarget

        if context is None or default == '':
            # the edit zpts like typesAliases don't apply a context and set the
            # default to ''. We do not want to resolve (dynamic view) for these
            # methods.
            return methodTarget

        # Our two special targets:

        if methodTarget.lower() == "(dynamic view)":
            methodTarget = self.defaultView(context)

        if methodTarget.lower() == "(selected layout)":
            fallback = self.default_view_fallback
            methodTarget = self.getViewMethod(context, check_exists=fallback)

        return methodTarget
コード例 #8
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
コード例 #9
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
コード例 #10
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
コード例 #11
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
コード例 #12
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)
コード例 #13
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")
コード例 #14
0
ファイル: DocumentBank.py プロジェクト: ksiktforum/ksiktforum
 def _constructInstance(self, container, id, *args, **kw):
     topicmap = kw['topicmap'] = self.portal_topicmaps.getTopicMap()  
     ob = FactoryTypeInformation._constructInstance( self
                                                   , container
                                                   , id
                                                   , *args
                                                   , **kw
                                                   )        
     ob.addType(psis.documentbank)
     
     
     #ob.invokeFactory(id='filearchive', type_name='CMF BTree Folder')        
     #ob.invokeFactory(id='discussion', type_name='CMF BTree Folder')        
     #getattr(ob, 'filearchive').__parent__ = ob
     #getattr(ob, 'discussion').__parent__ = ob        
     
     return ob
コード例 #15
0
ファイル: WorkArea.py プロジェクト: ksiktforum/ksiktforum
 def _constructInstance(self, container, id, *args, **kw):
     topicmap = kw['topicmap'] = self.portal_topicmaps.getTopicMap()  
     ob = FactoryTypeInformation._constructInstance( self
                                                   , container
                                                   , id
                                                   , *args
                                                   , **kw
                                                   )        
     ob.addType(psis.workarea)
     
     
     ob.invokeFactory(id='filer', type_name='CMF BTree Folder')        
     ob.invokeFactory(id='diskusjoner', type_name='CMF BTree Folder')        
     getattr(ob, 'filer').__parent__ = ob
     getattr(ob, 'diskusjoner').__parent__ = ob        
     
     return ob
コード例 #16
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
コード例 #17
0
    def _populate(self, obj):
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        obj._setObject('foo_type', FactoryTypeInformation('foo_type'))
コード例 #18
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' )
コード例 #19
0
ファイル: test_typeinfo.py プロジェクト: bendavis78/zope
 def setUp(self):
     BodyAdapterTestCase.setUp(self)
     self._obj = FactoryTypeInformation('foo_fti')
     self._BODY = _FTI_BODY
コード例 #20
0
    def _makeInstance(self, id, **kw):
        from Products.CMFCore.TypesTool import FactoryTypeInformation

        return FactoryTypeInformation(id, **kw)
コード例 #21
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
コード例 #22
0
 def _populate(self, obj):
     obj._setObject('foo_type', FactoryTypeInformation('foo_type'))
コード例 #23
0
 def setUp(self):
     self._obj = FactoryTypeInformation('foo_fti')
     self._BODY = _FTI_BODY
コード例 #24
0
 def setUp(self):
     self._obj = FactoryTypeInformation('foo_fti')
     self._BODY = _FTI_BODY
     self._trap_warning_output()