コード例 #1
0
def setupSkin(self, out):
    skinsTool = getToolByName(self, 'portal_skins')
    
    # Add directory views
    try:  
        addDirectoryViews(skinsTool, 'skins', GLOBALS)
        out.write( "Added directory views to portal_skins.\n" )
    except:
        out.write( '*** Unable to add directory views to portal_skins.\n')

    # Go through the skin configurations and insert the skin
    skins = skinsTool.getSkinSelections()
    for skin in skins:
        path = skinsTool.getSkinPath(skin)
        path = map(string.strip, string.split(path,','))
        changed = 0
        for skin_name in skin_names:
            if skin_name not in path:
                try: 
                    path.insert(path.index('custom')+1, skin_name)
                    changed = 1
                except ValueError:
                    path.append(skin_name)
                    changed = 1

        if changed:        
            path = string.join(path, ', ')
            # addSkinSelection will replace existing skins as well.
            skinsTool.addSkinSelection(skin, path)
            out.write("Added %s to %s skin\n" % (', '.join(skin_names),skin))
        else:
            out.write("Skipping %s skin, %s already set up\n" % (skin, ', '.join(skin_names)))
コード例 #2
0
ファイル: SkinInstaller.py プロジェクト: a25kk/stv2
    def doInstall(self, context):
        """Process installation of new skin
        @param context: InstallationContext object
        """

        def commonItems(s1, s2):
            """Returns items in both sequences s1 and s2
            """
            result = []
            for item in s1:
                if item in s2:
                    result.append(item)
            return result

        installed_skins = context.portal_skins.getSkinSelections()
        if not self.skin_name in installed_skins:
            addDirectoryViews(context.portal_skins, self.layers_dir, context.product_globals)
            # Make [['layer1', 'layer2', ...], ['layer1', 'layer2', ...]]
            paths = [x[1] for x in context.portal_skins.getSkinPaths()]
            paths = [x.split(",") for x in paths]
            paths = [[x.strip() for x in path] for path in paths]
            # Find common layers of all skins
            paths = reduce(commonItems, paths)
            for layer in self.new_layers:
                if layer not in paths:
                    paths.insert(paths.index("custom") + 1, layer)
            paths = ",".join(paths)
            context.portal_skins.addSkinSelection(self.skin_name, paths)
            context.logInfo("Skin '%s' installed in portal skins properties" % self.skin_name)
            if self.is_default:
                context.portal_skins.default_skin = self.skin_name
                context.logInfo("And is the default skin")
        else:
            context.logWarning("There is already a skin named '%s', skipped" % self.skin_name)
        return
コード例 #3
0
 def setUp(self):
     self._trap_warning_output()
     from Products.CMFCore.DirectoryView import registerDirectory
     from Products.CMFCore.DirectoryView import addDirectoryViews
     registerDirectory('fake_skins', _prefix)
     self.ob = DummyFolder()
     addDirectoryViews(self.ob, 'fake_skins', _prefix)
コード例 #4
0
ファイル: Installation.py プロジェクト: dtgit/dtedu
    def setupTypesandSkins(self, fti_list, skin_name, install_globals):
        """
        setup of types and skins
        """

        # Former types deletion (added by PJG)
        for f in fti_list:
            if f['id'] in self.typesTool.objectIds():
                self.out.write('*** Object "%s" already existed in the types tool => deleting\n' % (f['id']))
                self.typesTool._delObject(f['id'])

        # Type re-creation
        for f in fti_list:
            # Plone1 : if cmfformcontroller is not available and plone1_action key is defined,
            # use this key instead of the regular 'action' key.
            if (not self.hasFormController()) and f.has_key('plone1_action'):
                f['action'] = f['plone1_action']

            # Regular FTI processing
            cfm = apply(ContentFactoryMetadata, (), f)
            self.typesTool._setObject(f['id'], cfm)
            self.out.write('Type "%s" registered with the types tool\n' % (f['id']))

        # Install de chaque nouvelle subskin/layer
        try:
            addDirectoryViews(self.skinsTool, 'skins', install_globals)
            self.out.write( "Added directory views to portal_skins.\n" )
        except:
            self.out.write( '*** Unable to add directory views to portal_skins.\n')

        # Param de chaque nouvelle subskin/layer
        self.installSubSkin(skin_name)
コード例 #5
0
ファイル: SkinLayersInstaller.py プロジェクト: a25kk/stv2
    def doInstall(self, context):
        """Process installation of new layers
        @param context: InstallationContext object
        """
        # Get the list of installed layers
        before_layers = context.portal_skins.objectIds()

        # Process installation
        addDirectoryViews(context.portal_skins, self.layers_dir, context.product_globals)

        # Register in the skins selection
        after_layers = context.portal_skins.objectIds()
        new_layers = [l for l in after_layers if not l in before_layers]

        # FIXME: find something to reorder the various layers...
        for skin_name in context.portal_skins.getSkinSelections():
            path = [l.strip() for l in context.portal_skins.getSkinPath(skin_name).split(',')]
            for new_layer in new_layers:
                if new_layer not in path:
                    try:
                        path.insert(path.index(self.marker) + 1, new_layer)
                        context.logInfo("Added '%s' layer after '%s' in '%s' skin" %
                                        (new_layer, self.marker, skin_name))
                    except ValueError, e:
                        path.append(new_layer)
                        context.logWarning("Appended '%s' layer to '%s' skin (layer '%s' not found)" %
                                           (new_layer, skin_name, self.marker))
                else:
                    context.logWarning("Layer '%s' already in '%s' skin, skipped" %
                                       (new_layer, skin_name))
                # /if ...
            # /for ...
            path = ', '.join(path)
            context.portal_skins.addSkinSelection(skin_name, path)
コード例 #6
0
def registerSkin(self, base, positionAfter='custom'):
    """setup the skins in a product"""
    layers = skinDirs(base)
    try:
        from Products.CMFCore.utils import getToolByName
        from Products.CMFCore.DirectoryView import addDirectoryViews
        skinstool = getToolByName(self, 'portal_skins')
        for layer in layers:
            if layer not in skinstool.objectIds():
                path = os.path.join(base, 'skins')
                if not os.path.exists(path): os.mkdir(path, mode=0755)
                root = findZenPackRoot(path).split('/')[-1]
                addDirectoryViews(skinstool, path, dict(__name__=root))
        skins = skinstool.getSkinSelections()
        for skin in skins:
            path = skinstool.getSkinPath(skin)
            path = map(string.strip, string.split(path,','))
            for layer in layers:
                if layer not in path:
                    try:
                        path.insert(path.index(positionAfter)+1, layer)
                    except ValueError:
                        path.append(layer)
            path = ','.join(path)
            skinstool.addSkinSelection(skin, path)
    except ImportError, e:
        if "Products.CMFCore.utils" in e.args: pass
        else: raise
コード例 #7
0
def installSkins(self, portal, out):
    """
    Instala as skins em portal_skins e regitra os layers correspondentes.
    """

    skins_tool = getToolByName(portal, 'portal_skins')
    skins = skins_tool.getSkinSelections()

    for skin in skins:
        path = skins_tool.getSkinPath(skin)
        path = map(string.strip, string.split(path,','))
        if SKIN_NAME not in path:
            try:
                path.insert(path.index('custom') + 1, SKIN_NAME)
            except ValueError:
                path.append(SKIN_NAME)

            path = string.join(path, ', ')
            skins_tool.addSkinSelection(skin, path)
            out.write('Adicionado %s na skin %s\n' % (SKIN_NAME, skin))
        else:
            out.write('Saltando a skin %s, %s ja esta configurado\n' % (skin, SKIN_NAME))

    skins = skins_tool.getSkinSelections()

    if SKIN_NAME not in skins_tool.objectIds():
        addDirectoryViews(skins_tool, SKINS_DIR, GLOBALS)
        out.write('Adicionado o directory view %s ao portal_skins\n' % SKIN_NAME)
    else:
        out.write('O directory view %s ja existe no portal_skins\n' % SKIN_NAME)
コード例 #8
0
 def initTableManagerSkins(self):
     """setup the skins that come with ZenTableManager"""
     layers = ('zentablemanager','zenui')
     try:
         import string
         from Products.CMFCore.utils import getToolByName
         from Products.CMFCore.DirectoryView import addDirectoryViews
         skinstool = getToolByName(self, 'portal_skins')
         for layer in layers:
             if layer not in skinstool.objectIds():
                 addDirectoryViews(skinstool, 'skins', globals())
         skins = skinstool.getSkinSelections()
         for skin in skins:
             path = skinstool.getSkinPath(skin)
             path = map(string.strip, string.split(path,','))
             for layer in layers:
                 if layer not in path:
                     try:
                         path.insert(path.index('custom')+1, layer)
                     except ValueError:
                         path.append(layer)
             path = ','.join(path)
             skinstool.addSkinSelection(skin, path)
     except ImportError, e:
         if "Products.CMFCore.utils" in e.args: pass
         else: raise
コード例 #9
0
ファイル: testcase.py プロジェクト: goschtl/zope
 def _registerDirectory(self,object=None):
     from Products.CMFCore.DirectoryView import registerDirectory
     from Products.CMFCore.DirectoryView import addDirectoryViews
     registerDirectory(self._skinname, self.tempname)
     if object is not None:
         ob = self.ob = DummyFolder()
         addDirectoryViews(ob, self._skinname, self.tempname)
コード例 #10
0
 def setupDefaultSkins(self, p):
     from Products.CMFCore.DirectoryView import addDirectoryViews
     ps = getToolByName(p, 'portal_skins')
     addDirectoryViews(ps, 'skins', globals())
     ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
     ps.addSkinSelection('Basic', "custom, zenmodel", make_default=1)
     p.setupCurrentSkin()
コード例 #11
0
    def setupTypesandSkins(self, fti_list, skin_name, install_globals, fti_list2=None):
        """
        setup of types and skins
        """
        if self.hasFormController() and fti_list2:
            fti_list = fti_list2

        # Former types deletion (added by PJG)
        for f in fti_list:
            if f['id'] in self.typesTool.objectIds():
                self.out.write('*** Object "%s" already existed in the types tool => deleting\n' % (f['id']))
                self.typesTool._delObject(f['id'])

        # Type re-creation
        for f in fti_list:
            # Regular FTI processing
            cfm = apply(FactoryTypeInformation, (), f)
            self.typesTool._setObject(f['id'], cfm)
            self.out.write('Type "%s" registered with the types tool\n' % (f['id']))

        # Install de chaque nouvelle subskin/layer
        try:  
            addDirectoryViews(self.skinsTool, 'skins', install_globals)
            self.out.write( "Added directory views to portal_skins.\n" )
        except:
            self.out.write( '*** Unable to add directory views to portal_skins.\n')

        # Param de chaque nouvelle subskin/layer
        self.installSubSkin(skin_name)
コード例 #12
0
ファイル: testcase.py プロジェクト: bendavis78/zope
 def _registerDirectory(self, object=None):
     from Products.CMFCore.DirectoryView import registerDirectory
     from Products.CMFCore.DirectoryView import addDirectoryViews
     registerDirectory(self._skinname, self.tempname)
     if object is not None:
         ob = self.ob = DummyFolder()
         addDirectoryViews(ob, self._skinname, self.tempname)
コード例 #13
0
ファイル: utils.py プロジェクト: jordialcoister/LDP-Valencia
def install_subskin(self, out, skin_name, globals=types_globals):
    homedir = package_home(globals)
    log("Skins are in the %s subdirectory of %s" % (skin_name, homedir))
    skinstool = getToolByName(self, "portal_skins")
    if skin_name not in skinstool.objectIds():
        registerDirectory(skin_name, homedir)
        try:
            addDirectoryViews(skinstool, skin_name, homedir)
        except:
            log("Error adding directory views for " + skin_name)

    for skinName in skinstool.getSkinSelections():
        path = skinstool.getSkinPath(skinName)
        path = [i.strip() for i in path.split(",")]

        # Delete it if it already exists, so it only exists once.
        for skin_dir in SKIN_DIRS:
            if skin_dir in path:
                path.remove(skin_dir)

            try:
                if skin_dir not in path:
                    path.insert(path.index("custom") + 1, skin_dir)
            except ValueError:
                if skin_dir not in path:
                    path.append(skin_dir)

        path = ",".join(path)
        skinstool.addSkinSelection(skinName, path)
コード例 #14
0
    def installIntoPortal(self):
        """Install skins into portal.
        """
        from Products.CMFCore.utils import getToolByName
        from Products.CMFCore.DirectoryView import addDirectoryViews
        from cStringIO import StringIO
        import string

        out = StringIO()
        skinstool = getToolByName(self, 'portal_skins')
        if 'zenevents' not in skinstool.objectIds():
            addDirectoryViews(skinstool, 'skins', globals())
            out.write("Added 'zenevents' directory view to portal_skins\n")
        skins = skinstool.getSkinSelections()
        for skin in skins:
            path = skinstool.getSkinPath(skin)
            path = map(string.strip, string.split(path,','))
            if 'zenevents' not in path:
                try: path.insert(path.index('zenmodel'), 'zenevents')
                except ValueError:
                    path.append('zenevents')
                path = string.join(path, ', ')
                skinstool.addSkinSelection(skin, path)
                out.write("Added 'zenevents' to %s skin\n" % skin)
            else:
                out.write(
                    "Skipping %s skin, 'zenevents' is already set up\n" % skin)
        return out.getvalue()
コード例 #15
0
    def installIntoPortal(self):
        """Install skins into portal.
        """
        from Products.CMFCore.utils import getToolByName
        from Products.CMFCore.DirectoryView import addDirectoryViews
        from cStringIO import StringIO
        import string

        out = StringIO()
        skinstool = getToolByName(self, 'portal_skins')
        if 'zenevents' not in skinstool.objectIds():
            addDirectoryViews(skinstool, 'skins', globals())
            out.write("Added 'zenevents' directory view to portal_skins\n")
        skins = skinstool.getSkinSelections()
        for skin in skins:
            path = skinstool.getSkinPath(skin)
            path = map(string.strip, string.split(path, ','))
            if 'zenevents' not in path:
                try:
                    path.insert(path.index('zenmodel'), 'zenevents')
                except ValueError:
                    path.append('zenevents')
                path = string.join(path, ', ')
                skinstool.addSkinSelection(skin, path)
                out.write("Added 'zenevents' to %s skin\n" % skin)
            else:
                out.write("Skipping %s skin, 'zenevents' is already set up\n" %
                          skin)
        return out.getvalue()
コード例 #16
0
def registerSkin(self, base, positionAfter='custom'):
    """setup the skins in a product"""
    layers = skinDirs(base)
    try:
        from Products.CMFCore.utils import getToolByName
        from Products.CMFCore.DirectoryView import addDirectoryViews
        skinstool = getToolByName(self, 'portal_skins')
        for layer in layers:
            if layer not in skinstool.objectIds():
                path = os.path.join(base, 'skins')
                if not os.path.exists(path): os.mkdir(path, mode=0755)
                root = findZenPackRoot(path).split('/')[-1]
                addDirectoryViews(skinstool, path, dict(__name__=root))
        skins = skinstool.getSkinSelections()
        for skin in skins:
            path = skinstool.getSkinPath(skin)
            path = map(string.strip, string.split(path, ','))
            for layer in layers:
                if layer not in path:
                    try:
                        path.insert(path.index(positionAfter) + 1, layer)
                    except ValueError:
                        path.append(layer)
            path = ','.join(path)
            skinstool.addSkinSelection(skin, path)
    except ImportError as e:
        if "Products.CMFCore.utils" in e.args: pass
        else: raise
    except AttributeError as e:
        if "portal_skin" in e.args: pass
        else: raise
コード例 #17
0
ファイル: utils.py プロジェクト: a25kk/stv2
def installSkin(portal, pp_up, out):
    # Checking for presense SKIN_NAME in portal_skins directory view or among Skin Names
    skinsTool = getToolByName(portal, 'portal_skins')
    # Get unique product_skin_name and remember it in case of differ from SKIN_NAME.
    product_skin_name = SKIN_NAME
    skin_names = skinsTool.getSkinSelections()
    if product_skin_name in skin_names:
        idx = 0
        while product_skin_name in skin_names:
            product_skin_name = SKIN_NAME + str(idx)
            idx += 1
        addProperty(pp_up, 'q_actual_skin_name', product_skin_name, 'string', out)
    # Add directory views
    layer_skin_name = string.lower(SKIN_NAME)
    addDirectoryViews(skinsTool, 'skins', GLOBALS)
    print >> out,  "- added '%s' directory views to portal_skins." % layer_skin_name
    # Get Default skin and remember it for backup on uninstallig
    default_skin = skinsTool.getDefaultSkin()
    addProperty(pp_up, 'q_default_skin', default_skin, 'string', out)
    # Building list of layers for NEW SKIN
    base_path = skinsTool.getSkinPath(BASE_SKIN_NAME)
    new_path = map( string.strip, string.split(base_path,',') )
    if layer_skin_name in new_path :
        print >> out, "- %s layer already present in '%s' skin." % (layer_skin_name, BASE_SKIN_NAME)
        # Remove layer_skin_name from current position.
        del new_path[new_path.index(layer_skin_name)]
    # Add layer_skin_name just after 'custom' position
    try: 
        new_path.insert(new_path.index('custom')+1, layer_skin_name)
    except ValueError:
        new_path.append(layer_skin_name)
    new_path = string.join(new_path, ', ')
    # Add NEW Skin and set it as dafault
    skinsTool.addSkinSelection(product_skin_name, new_path, make_default=1)
    print >> out, "Added %s skin, bassed on %s and set as default." % (product_skin_name, BASE_SKIN_NAME)
コード例 #18
0
ファイル: test_DirectoryView.py プロジェクト: goschtl/zope
 def setUp(self):
     self._trap_warning_output()
     from Products.CMFCore.DirectoryView import registerDirectory
     from Products.CMFCore.DirectoryView import addDirectoryViews
     registerDirectory('fake_skins', _prefix)
     self.ob = DummyFolder()
     addDirectoryViews(self.ob, 'fake_skins', _prefix)
コード例 #19
0
ファイル: utils.py プロジェクト: dnessorga/LDP
def install_subskin(self, out, skin_name, globals=types_globals):
    homedir=package_home(globals)
    log('Skins are in the %s subdirectory of %s' % (skin_name, homedir))
    skinstool=getToolByName(self, 'portal_skins')
    if skin_name not in skinstool.objectIds():
        registerDirectory(skin_name, homedir)
        try:
            addDirectoryViews(skinstool, skin_name, homedir)
        except:
            log('Error adding directory views for ' + skin_name)

    for skinName in skinstool.getSkinSelections():
        path = skinstool.getSkinPath(skinName) 
        path = [i.strip() for i in  path.split(',')]

        # Delete it if it already exists, so it only exists once.
        for skin_dir in SKIN_DIRS:
            if skin_dir in path:
                path.remove(skin_dir)

            try:
                if skin_dir not in path:
                    path.insert(path.index('custom') +1, skin_dir)
            except ValueError:
                if skin_dir not in path:
                    path.append(skin_dir)  

        path = ','.join(path)
        skinstool.addSkinSelection( skinName, path)
コード例 #20
0
def install(self):
    " Register the CMF Topic with portal_types and friends "
    out = StringIO()
    typestool = getToolByName(self, 'portal_types')
    skinstool = getToolByName(self, 'portal_skins')
    workflowtool = getToolByName(self, 'portal_workflow')

    # Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
    # We loop through anything defined in the factory type information
    # and configure it in the types tool if it doesn't already exist
    for t in CMFWikiPage.factory_type_information:
        if t['id'] not in typestool.objectIds():
            cfm = apply(ContentFactoryMetadata, (), t)
            typestool._setObject(t['id'], cfm)
            out.write('Registered %s with the types tool\n' % t['id'])
        else:
            out.write('Object "%s" already existed in the types tool\n' %
                      (t['id']))

    # Setup the skins
    # This is borrowed from CMFDefault/scripts/addImagesToSkinPaths.pys
    if 'wiki' not in skinstool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews(skinstool, 'skins', wiki_globals)
        out.write("Added 'wiki' directory view to portal_skins\n")

    # Now we need to go through the skin configurations and insert
    # 'wiki' into the configurations.  Preferably, this should be
    # right before where 'content' is placed.  Otherwise, we append
    # it to the end.
    skins = skinstool.getSkinSelections()
    for skin in skins:
        path = skinstool.getSkinPath(skin)
        path = map(string.strip, string.split(path, ','))
        for dir in ('wiki', 'zpt_wiki'):

            if not dir in path:
                try:
                    idx = path.index('custom')
                except ValueError:
                    idx = 999
                path.insert(idx + 1, dir)

        path = string.join(path, ', ')
        # addSkinSelection will replace existing skins as well.
        skinstool.addSkinSelection(skin, path)
        out.write("Added 'wiki' and 'zpt_wiki' to %s skin\n" % skin)

    # remove workflow for Wiki pages
    cbt = workflowtool._chains_by_type
    if cbt is None:
        cbt = PersistentMapping()
    cbt['CMF Wiki'] = []
    cbt['CMF Wiki Page'] = []
    workflowtool._chains_by_type = cbt
    out.write("Removed all workflow from CMF Wikis and CMF Wiki Pages")
    return out.getvalue()
コード例 #21
0
ファイル: Install.py プロジェクト: goschtl/zope
def install(self):
    " Register the CMF Topic with portal_types and friends "
    out = StringIO()
    typestool = getToolByName(self, 'portal_types')
    skinstool = getToolByName(self, 'portal_skins')
    workflowtool = getToolByName(self, 'portal_workflow')
    
    # Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
    # We loop through anything defined in the factory type information
    # and configure it in the types tool if it doesn't already exist
    for t in CMFWikiPage.factory_type_information:
        if t['id'] not in typestool.objectIds():
            cfm = apply(ContentFactoryMetadata, (), t)
            typestool._setObject(t['id'], cfm)
            out.write('Registered %s with the types tool\n' % t['id'])
        else:
            out.write('Object "%s" already existed in the types tool\n' % (
                t['id']))

     # Setup the skins
     # This is borrowed from CMFDefault/scripts/addImagesToSkinPaths.pys
    if 'wiki' not in skinstool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews(skinstool, 'skins', wiki_globals)
        out.write("Added 'wiki' directory view to portal_skins\n")

    # Now we need to go through the skin configurations and insert
    # 'wiki' into the configurations.  Preferably, this should be
    # right before where 'content' is placed.  Otherwise, we append
    # it to the end.
    skins = skinstool.getSkinSelections()
    for skin in skins:
        path = skinstool.getSkinPath(skin)
        path = map(string.strip, string.split(path,','))
        for dir in ( 'wiki', 'zpt_wiki' ):

            if not dir in path:
                try:
                    idx = path.index( 'custom' )
                except ValueError:
                    idx = 999
                path.insert( idx+1, dir )

        path = string.join(path, ', ')
        # addSkinSelection will replace existing skins as well.
        skinstool.addSkinSelection(skin, path)
        out.write("Added 'wiki' and 'zpt_wiki' to %s skin\n" % skin)

    # remove workflow for Wiki pages
    cbt = workflowtool._chains_by_type
    if cbt is None:
        cbt = PersistentMapping()
    cbt['CMF Wiki'] = []
    cbt['CMF Wiki Page'] = []
    workflowtool._chains_by_type = cbt
    out.write("Removed all workflow from CMF Wikis and CMF Wiki Pages")
    return out.getvalue()
コード例 #22
0
ファイル: Install.py プロジェクト: kroman0/products
def install(self):
    out=StringIO()
    skinsTool = getToolByName(self, 'portal_skins')
    # Add directory views
    try:  
        addDirectoryViews(skinsTool, SKINS_DIR, GLOBALS)
        out.write( "Added directory views to portal_skins.\n" )
    except:
        out.write( '*** Unable to add directory views to portal_skins.\n')

    # Checking for presense SKIN_NAME Layer in available skins
    avail_skin_names = skinsTool.getSkinSelections()
    if SKIN_NAME in avail_skin_names :
        out.write("Skipping creation %s skin, %s already set up\n" % (SKIN_NAME) )
        return

    for skin in avail_skin_names:
        # Get skin's layers
        skin_layers = skinsTool.getSkinPath(skin)
        skin_layers_list = map( string.strip, string.split(skin_layers,',') )
        if not (SKIN_NAME in skin_layers_list) :
            # Insert new layer after 'custom'
            try: 
                skin_layers_list.insert(skin_layers_list.index('custom')+1 \
                                        , string.lower(SKIN_NAME) )
            except ValueError:
                skin_layers_list.append(string.lower(SKIN_NAME) )

            # Add new skin Layer
            new_skin_layers = string.join(skin_layers_list, ', ')
            skinsTool.addSkinSelection(skin, new_skin_layers)
            out.write("%s skin-layer was added to %s skin\n" % (SKIN_NAME, skin) )
        else:
            out.write("Skipping adding %s skin-layer, to %s skin\n" % (SKIN_NAME, skin) )

    # add Property sheet to portal_properies
    pp = getToolByName(self, 'portal_properties')
    if not PROPERTY_SHEET in pp.objectIds():
        pp.addPropertySheet(id=PROPERTY_SHEET, title= '%s Properties' % PROPERTY_SHEET)
        out.write("Adding %s property sheet to portal_properies\n" % PROPERTY_SHEET )
    props_sheet = pp[PROPERTY_SHEET]
    updateProperty(props_sheet, id="Email_of_discussion_manager", value="", property_type='string', out=out)
    updateProperty(props_sheet, id="Turning_on/off_notification", value="True", property_type='boolean', out=out)
    updateProperty(props_sheet, id="Turning_on/off_Moderation", value="True", property_type='boolean', out=out)
    updateProperty(props_sheet, id="Turning_on/off_Anonymous_Commenting", value="True", property_type='boolean', out=out)
    out.write("Updating properties of %s property sheet\n" % PROPERTY_SHEET )

    # Add Configlet. Delete old version before adding, if exist one.
    controlpanel_tool = getToolByName(self, 'portal_controlpanel')
    controlpanel_tool.unregisterConfiglet(CONFIGLET_ID)
    controlpanel_tool.registerConfiglet(id=CONFIGLET_ID, name=CONFIGLET_NAME, category='Products',
                                        action='string:${portal_url}/qPloneComments_config',
                                        appId=PROJECTNAME, permission=ManagePortal, imageUrl='group.gif')


    
    out.write('Installation successfully completed.\n')
    return out.getvalue()
コード例 #23
0
ファイル: Install.py プロジェクト: glehmann/bdr
def install(self):
	"""Register skin layer with skin tool, and other setup in the future """
	directory_name = 'BDR'
	
	out = StringIO() # setup stream for status messages
	
	# setup the skins
	skinstool = getToolByName(self, 'portal_skins')
	if directory_name not in skinstool.objectIds():
		# we need to add FileSystem Directory Views for any
		# directories in our skins/ directory
		# These directories should already be configured
		# ajoute le skin dans le portal_skins
		addDirectoryViews(skinstool, 'skins', product_globals)
		out.write("Added %s directory view to portal_skins\n" % directory_name)
	
		
	# Now we need to go through the skin configurations and insert directory_name into the configurations.
	# preferabily, this should be right after where 'custom' is placed.
	# Otherwise, we append it to the end
	
	# ajoute le skin dans les configurations, si possible apres custom, pour le mettre le plus haut dans les priorites
	skins = skinstool.getSkinSelections()
	for skin in skins:
		path=skinstool.getSkinPath(skin)
		path=map(string.strip, string.split(path,','))
		if directory_name not in path:
			try: path.insert(path.index('custom')+1, directory_name)
			except ValueError:
				path.append(directory_name)
			path = string.join(path,', ')
			skinstool.addSkinSelection(skin, path)
			out.write("Added %s to %s skin \n" % (directory_name, skin))

		else:
			out.write("Skipping %s skin, %s is already set up\n" % (skin, directory_name))
	
	
	
	# portal Properties
	
	
	urltool = getToolByName(self,'portal_url')
	portal = urltool.getPortalObject()
	if not(hasattr(portal,'old_properties')):
		portal.old_properties={}

	# sauvegarde les anciennes proprietes dans la propriete old_properties
	
	
	for new_property in new_properties:
		portal.old_properties[new_property] = getattr(portal,new_property)
	
	# et met a jour les proprietes courantes
	portal.manage_changeProperties(new_properties)
	
	return out.getvalue()
コード例 #24
0
def install(self):
    outStream = StringIO()
    skinsTool = getToolByName(self, 'portal_skins')
    addDirectoryViews(skinsTool, 'skins', config.GLOBALS)
    installSubSkin(self, config.SKIN_NAME, outStream)
    addTool(self)
    installConfiglet(self, outStream)
    registerJavaScript(self, outStream)
    return outStream.getvalue()
コード例 #25
0
ファイル: Install.py プロジェクト: dipp/Products.CMFOpenflow
def install( self ):
    """ Setup CMFOpenflow """
    msg = ""
    try:
        openflow_id = 'portal_openflow'
        if self.objectValues('CMF OpenFlow Tool'):
            msg += "Delete old portal_openflow..."
            self.manage_delObjects(openflow_id)
            msg += "Done\n"
        msg += "Add new portal_openflow..."
        self.manage_addProduct['CMFOpenflow'].manage_addOpenflow(openflow_id)
        msg += "Done\n"

        portal_actions = getToolByName( self, 'portal_actions')
        if 'worklist' in [action.id for action in portal_actions.listActions()]:
            msg += "Delete old action worklist to portal..."
            listA = portal_actions.listActions()
            selections = tuple([i for i in range(0,len(listA)) if listA[i].id=='worklist'])
            portal_actions.deleteActions(selections)
            msg += "Done\n"
        msg += "Add new action worklist to portal..."
        portal_actions.addAction(
                    id='worklist',
                    name='Worklist',
                    action='string: ${portal_url}/worklist',
                    condition='',
                    permission='Use OpenFlow',
                    category='global',
                    visible=1)
        msg += "Done\n"

        skinstool = getToolByName( self, 'portal_skins' )
        msg += "Add Skins..."
        if 'zpt_cmfopenflow' not in skinstool.objectIds():
            addDirectoryViews( skinstool, 'skins', cmfopenflow_globals)
            #addDirectoryViews( skinstool, 'skins')
            msg += "---"
        skins = skinstool.getSkinSelections()
        for skin in skins:
            path = skinstool.getSkinPath( skin )
            path = map( string.strip, string.split(path, ',') )
            if 'zpt_cmfopenflow' not in path:
                try:
                    path.insert( path.index('content'), 'zpt_cmfopenflow' )
                except ValueError:
                    path.append( 'zpt_cmfopenflow' )
                path = string.join( path, ', ' )
                skinstool.addSkinSelection( skin, path )
        msg += "Done\n"

        msg += "OK\n"
    except:
        import sys
        msg += "Not done\n"
        msg += "Error: "+str(sys.exc_info()[0])+" "+str(sys.exc_info()[1])+" "+str(sys.exc_info()[2])+"\n"

    return msg
コード例 #26
0
ファイル: testcase.py プロジェクト: bendavis78/zope
 def _registerDirectory(self, object=None, ignore=None):
     self._trap_warning_output()
     from Products.CMFCore.DirectoryView import registerDirectory
     from Products.CMFCore.DirectoryView import addDirectoryViews
     if ignore is None:
         from Products.CMFCore.DirectoryView import ignore
     registerDirectory(self._skinname, self.tempname, ignore=ignore)
     if object is not None:
         ob = self.ob = DummyFolder()
         addDirectoryViews(ob, self._skinname, self.tempname)
コード例 #27
0
def addTestLayer(self):
    # Install test_captcha skin layer
    registerDirectory("tests", GLOBALS)
    skins = self.portal.portal_skins
    addDirectoryViews(skins, "tests", GLOBALS)
    skinName = skins.getDefaultSkin()
    paths = map(string.strip, skins.getSkinPath(skinName).split(","))
    paths.insert(paths.index("custom") + 1, "test_captcha")
    skins.addSkinSelection(skinName, ",".join(paths))
    self._refreshSkinData()
コード例 #28
0
def addTestLayer(self):
    # Install test_captcha skin layer
    registerDirectory('tests', GLOBALS)
    skins = self.portal.portal_skins
    addDirectoryViews(skins, 'tests', GLOBALS)
    skinName = skins.getDefaultSkin()
    paths = map(string.strip, skins.getSkinPath(skinName).split(','))
    paths.insert(paths.index('custom') + 1, 'test_captcha')
    skins.addSkinSelection(skinName, ','.join(paths))
    self._refreshSkinData()
コード例 #29
0
ファイル: testcase.py プロジェクト: CGTIC/Plone_SP
 def _registerDirectory(self, object=None, ignore=None):
     self._trap_warning_output()
     from Products.CMFCore.DirectoryView import registerDirectory
     from Products.CMFCore.DirectoryView import addDirectoryViews
     if ignore is None:
         from Products.CMFCore.DirectoryView import ignore
     registerDirectory(self._skinname, self.tempname, ignore=ignore)
     if object is not None:
         ob = self.ob = DummyFolder()
         addDirectoryViews(ob, self._skinname, self.tempname)
コード例 #30
0
 def setupDefaultSkins(self, p):
     from Products.CMFCore.DirectoryView import addDirectoryViews
     ps = getToolByName(p, 'portal_skins')
     addDirectoryViews(ps, 'skins', globals())
     addDirectoryViews(ps, 'skins', topic_globals)
     ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
     ps.addSkinSelection('Basic',
                         'custom, zpt_topic, zpt_content, zpt_generic,' +
                         'zpt_control, Images',
                         make_default=1)
     p.setupCurrentSkin()
コード例 #31
0
ファイル: Portal.py プロジェクト: goschtl/zope
 def setupDefaultSkins(self, p):
     from Products.CMFCore.DirectoryView import addDirectoryViews
     ps = getToolByName(p, 'portal_skins')
     addDirectoryViews(ps, 'skins', globals())
     addDirectoryViews(ps, 'skins', topic_globals)
     ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
     ps.addSkinSelection('Basic',
         'custom, zpt_topic, zpt_content, zpt_generic,'
         + 'zpt_control, Images',
         make_default=1)
     p.setupCurrentSkin()
コード例 #32
0
ファイル: Install.py プロジェクト: smartinm/plone-meteo
def install(self):
    outStream = StringIO()

    skinsTool = getToolByName(self, 'portal_skins')
    addDirectoryViews(skinsTool, SKINS_DIR, GLOBALS)
    installSubSkin(self, 'meteo', outStream)
    install_css(self, outStream)
    addWeatherTool(self, outStream)
    installPortlet(self, outStream)
    installConfiglet(self, outStream)
    return outStream.getvalue()
コード例 #33
0
ファイル: Install.py プロジェクト: a25kk/stv2
def install(self) :
    outStream = StringIO()
    skinsTool = getToolByName(self, 'portal_skins')
    addDirectoryViews(skinsTool, 'skins', config.GLOBALS)
    installSubSkin(self, config.SKIN_NAME, outStream)
    #installSubSkin(self, config.SKIN_OVERLOAD_NAME, outStream)
    addTool(self, outStream)
    addPortlet(self, outStream)
    #addActionProvider(self)
    setupCSS(self, outStream)
    installConfiglet(self, outStream)
    return outStream.getvalue()
コード例 #34
0
ファイル: Install.py プロジェクト: carriercomm/selenium
def setupSkins(self, out):
    skinsTool = getToolByName(self, 'portal_skins')
            
    try:  
        addDirectoryViews(skinsTool, 'skins', selenium_globals)
        out.write( "Added directory views to portal_skins.\n" )
    except:
        out.write( '*** Unable to add directory views to portal_skins.\n')

    installSubSkin(self, out, "selenium_javascript")
    installSubSkin(self, out, "selenium_python_scripts")   
    installSubSkin(self, out, "selenium_test_results") 
    installSubSkin(self, out, "ftests_browser_driven") 
コード例 #35
0
 def setupDefaultSkins(self, p):
     from Products.CMFCore.DirectoryView import addDirectoryViews
     ps = getToolByName(p, 'portal_skins')
     addDirectoryViews(ps, 'skins', globals())
     ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
     ps.addSkinSelection('Basic',
                         'custom, content, generic, control',
                         make_default=1)
     ps.addSkinSelection('Nouvelle',
                         'nouvelle, custom, content, generic, control')
     ps.addSkinSelection('No CSS',
                         'no_css, custom, content, generic, control')
     p.setupCurrentSkin()
コード例 #36
0
ファイル: Portal.py プロジェクト: goschtl/zope
 def setupDefaultSkins(self, p):
     from Products.CMFCore.DirectoryView import addDirectoryViews
     ps = getToolByName(p, 'portal_skins')
     addDirectoryViews(ps, 'skins', globals())
     ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
     ps.addSkinSelection('Basic',
         'custom, content, generic, control, Images',
         make_default=1)
     ps.addSkinSelection('Nouvelle',
         'nouvelle, custom, content, generic, control, Images')
     ps.addSkinSelection('No CSS',
         'no_css, custom, content, generic, control, Images')
     p.setupCurrentSkin()
コード例 #37
0
ファイル: Install.py プロジェクト: goschtl/zope
def install( self, install_standard_mappings=1 ):
    """ Register the CMF ActionIcons tool and skins.
    """
    out = StringIO()
    skinstool = getToolByName( self, 'portal_skins' )
    portal_url = getToolByName( self, 'portal_url' )

    # Add the CMFActionIcons tool to the site's root
    p = portal_url.getPortalObject()
    x = p.manage_addProduct[ 'CMFActionIcons' ].manage_addTool(
                                        type='Action Icons Tool')


    out.write( "Added 'portal_actionicons' tool to site." )

    if install_standard_mappings:
        tool = getToolByName( p, 'portal_actionicons' )
        installActionIconMappings( tool )
        out.write( "Added standard mappings to the tool." )
    
    # Setup the skins
    if 'actionicons' not in skinstool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews( skinstool, 'skins', actionicons_globals )
        out.write( "Added 'actionicons' directory view to portal_skins\n" )

    # Now we need to go through the skin configurations and insert
    # 'actionicons' into the configurations.  Preferably, this should be
    # right after where 'custom' is placed.  Otherwise, we append
    # it to the end.
    skins = skinstool.getSkinSelections()
    for skin in skins:
        path = skinstool.getSkinPath( skin )
        path = [ x.strip() for x in path.split( ',' ) ]
        if 'actionicons' not in path:
            try:
                path.insert( path.index( 'custom' ) + 1, 'actionicons' )
            except ValueError:
                path.append( 'actionicons' )
                
            path = string.join( path, ', ' )
            # addSkinSelection will replace exissting skins as well.
            skinstool.addSkinSelection( skin, path )
            out.write( "Added 'actionicons' to %s skin\n" % skin )
        else:
            out.write( "Skipping %s skin, 'actionicons' is already set up\n"
                     % skin )

    return out.getvalue()
コード例 #38
0
def install(self):
    " Register the Collector with portal_types and friends "
    out = StringIO()
    types_tool = getToolByName(self, 'portal_types')
    skins_tool = getToolByName(self, 'portal_skins')
    metadata_tool = getToolByName(self, 'portal_metadata')
    catalog = getToolByName(self, 'portal_catalog')

    # Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
    # We loop through anything defined in the factory type information
    # and configure it in the types tool if it doesn't already exist
    for t in CMFCollector.factory_type_information:
        if t['id'] not in types_tool.objectIds():
            cfm = apply(ContentFactoryMetadata, (), t)
            types_tool._setObject(t['id'], cfm)
            out.write('Registered %s with the types tool\n' % t['id'])
        else:
            out.write('Skipping "%s" - already in types tool\n' % t['id'])

    # Setup the skins
    # This is borrowed from CMFDefault/scripts/addImagesToSkinPaths.pys
    if 'collector' not in skins_tool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews(skins_tool, 'skins', CMFCollector.collector_globals)
        out.write("Added collector skin directory view to portal_skins\n")

    # Now we need to go through the skin configurations and insert
    # 'collector' into the configurations.  Preferably, this should be
    # right before where 'content' is placed.  Otherwise, we append
    # it to the end.
    skins = skins_tool.getSkinSelections()
    for skin in skins:
        path = skins_tool.getSkinPath(skin)
        path = map(string.strip, string.split(path, ','))
        if 'collector' not in path:
            try:
                path.insert(path.index('content'), 'collector')
            except ValueError:
                path.append('collector')

            path = string.join(path, ', ')
            # addSkinSelection will replace exissting skins as well.
            skins_tool.addSkinSelection(skin, path)
            out.write("Added 'collector' to %s skin\n" % skin)
        else:
            out.write("Skipping %s skin, 'collector' is already set up\n" %
                      (skin))

    return out.getvalue()
コード例 #39
0
ファイル: Install.py プロジェクト: bendavis78/zope
def install( self, install_standard_mappings=1 ):
    """ Register the CMF ActionIcons tool and skins.
    """
    out = StringIO()
    skinstool = getToolByName( self, 'portal_skins' )
    portal_url = getToolByName( self, 'portal_url' )

    # Add the CMFActionIcons tool to the site's root
    p = portal_url.getPortalObject()
    x = p.manage_addProduct[ 'CMFActionIcons' ].manage_addTool(
                                        type='Action Icons Tool')


    out.write( "Added 'portal_actionicons' tool to site." )

    if install_standard_mappings:
        tool = getToolByName( p, 'portal_actionicons' )
        installActionIconMappings( tool )
        out.write( "Added standard mappings to the tool." )
    
    # Setup the skins
    if 'actionicons' not in skinstool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews( skinstool, 'skins', actionicons_globals )
        out.write( "Added 'actionicons' directory view to portal_skins\n" )

    # Now we need to go through the skin configurations and insert
    # 'actionicons' into the configurations.  Preferably, this should be
    # right after where 'custom' is placed.  Otherwise, we append
    # it to the end.
    skins = skinstool.getSkinSelections()
    for skin in skins:
        path = skinstool.getSkinPath( skin )
        path = [ x.strip() for x in path.split( ',' ) ]
        if 'actionicons' not in path:
            try:
                path.insert( path.index( 'custom' ) + 1, 'actionicons' )
            except ValueError:
                path.append( 'actionicons' )
                
            path = string.join( path, ', ' )
            # addSkinSelection will replace exissting skins as well.
            skinstool.addSkinSelection( skin, path )
            out.write( "Added 'actionicons' to %s skin\n" % skin )
        else:
            out.write( "Skipping %s skin, 'actionicons' is already set up\n"
                     % skin )

    return out.getvalue()
コード例 #40
0
    def install(self, aq_obj,position=None,mode='after',layerName=None):
        """Installs and registers the skin resources
        @param aq_obj: object from which cmf site object is acquired
        @type aq_obj: any Zope object in the CMF
        @return: Installation log
        @rtype: string
        """

        rpt = '=> Installing and registering layers from directory %s\n' % self._skinsdir
        skinstool = getToolByName(aq_obj, 'portal_skins')

        # Create the layer in portal_skins

        try:
            if self._skinsdir not in skinstool.objectIds():
                addDirectoryViews(skinstool, self._skinsdir, self._prodglobals)
                rpt += 'Added "%s" directory view to portal_skins\n' % self._skinsdir
            else:
                rpt += 'Warning: directory view "%s" already added to portal_skins\n' % self._skinsdir
        except:
            # ugh, but i am in stress
            rpt += 'Warning: directory view "%s" already added to portal_skins\n' % self._skinsdir


        # Insert the layer in all skins
        # XXX FIXME: Actually assumes only one layer directory with the name of the Product
        # (should be replaced by a smarter solution that finds individual Product's layers)

        if not layerName:
            layerName = self._prodglobals['__name__'].split('.')[-1]

        skins = skinstool.getSkinSelections()

        for skin in skins:
            layers = skinstool.getSkinPath(skin)
            layers = [layer.strip() for layer in layers.split(',')]
            if layerName not in layers:
                try:
                    pos=layers.index(position)
                    if mode=='after': pos=pos+1
                except ValueError:
                    pos=len(layers)

                layers.insert(pos, layerName)

                layers = ','.join(layers)
                skinstool.addSkinSelection(skin, layers)
                rpt += 'Added "%s" to "%s" skin\n' % (layerName, skin)
            else:
                rpt += '! Warning: skipping "%s" skin, "%s" is already set up\n' % (skin, type)
        return rpt
コード例 #41
0
ファイル: Install.py プロジェクト: goschtl/zope
def install(self):
    " Register the Collector with portal_types and friends "
    out = StringIO()
    types_tool = getToolByName(self, 'portal_types')
    skins_tool = getToolByName(self, 'portal_skins')
    metadata_tool = getToolByName(self, 'portal_metadata')
    catalog = getToolByName(self, 'portal_catalog')

    # Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
    # We loop through anything defined in the factory type information
    # and configure it in the types tool if it doesn't already exist
    for t in CMFCollector.factory_type_information:
        if t['id'] not in types_tool.objectIds():
            cfm = apply(ContentFactoryMetadata, (), t)
            types_tool._setObject(t['id'], cfm)
            out.write('Registered %s with the types tool\n' % t['id'])
        else:
            out.write('Skipping "%s" - already in types tool\n' % t['id'])

    # Setup the skins
    # This is borrowed from CMFDefault/scripts/addImagesToSkinPaths.pys
    if 'collector' not in skins_tool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews(skins_tool, 'skins', CMFCollector.collector_globals)
        out.write("Added collector skin directory view to portal_skins\n")

    # Now we need to go through the skin configurations and insert
    # 'collector' into the configurations.  Preferably, this should be
    # right before where 'content' is placed.  Otherwise, we append
    # it to the end.
    skins = skins_tool.getSkinSelections()
    for skin in skins:
        path = skins_tool.getSkinPath(skin)
        path = map(string.strip, string.split(path,','))
        if 'collector' not in path:
            try: path.insert(path.index('content'), 'collector')
            except ValueError:
                path.append('collector')
                
            path = string.join(path, ', ')
            # addSkinSelection will replace exissting skins as well.
            skins_tool.addSkinSelection(skin, path)
            out.write("Added 'collector' to %s skin\n" % skin)
        else:
            out.write("Skipping %s skin, 'collector' is already set up\n" % (
                skin))

    return out.getvalue()
コード例 #42
0
ファイル: Install.py プロジェクト: robcast/zsyncer
def install(self):
    " Register the ZSyncerTool with portal_types and friends "
    out = StringIO()
    skinstool = getToolByName(self, "portal_skins")
    urltool = getToolByName(self, "portal_url")
    actionstool = getToolByName(self, "portal_actions")

    # Add the ZSyncerTool tool to the site's root
    p = urltool.getPortalObject()
    tool_id = ZSyncerTool.id
    if not tool_id in p.objectIds():
        p.manage_addProduct["ZSyncer"].manage_addTool(type=ZSyncerTool.meta_type)
        out.write("Added %s tool\n" % tool_id)
    else:
        out.write("Already have %s tool, skipping\n" % tool_id)

    # Register Filesystem Directory View for our skins.
    skinfol_name = "zsyncer_skins"
    if skinfol_name not in skinstool.objectIds():
        # add Filesystem Directory Views for any sub-directories
        # in our skin/ directory.  These directories should already be
        # configured.  skin/ itself is NOT used for an FSDV.
        addDirectoryViews(skinstool, "skins", zs_globals)
        out.write("Added %s directory view to portal_skins\n" % skinfol_name)

    # add our new FSDV to all skinpaths, unless it already exists.
    # I'll just put it at the end.
    skins = skinstool.getSkinSelections()
    for skin in skins:
        path = skinstool.getSkinPath(skin)
        path = [s.strip() for s in path.split(",")]
        if skinfol_name not in path:
            path.append(skinfol_name)
            path = ", ".join(path)
            # addSkinSelection will replace existing skins as well.
            skinstool.addSkinSelection(skin, path)
            out.write("Added %s to %s skin\n" % (skinfol_name, skin))
        else:
            out.write("Skipping %s skin, %s is already set up\n" % (skin, skinfol_name))

    # Register as an Action Provider
    tool_id = ZSyncerTool.id
    if tool_id in actionstool.listActionProviders():
        out.write("%s is already registered as an action provider.\n" % tool_id)
    else:
        actionstool.addActionProvider(tool_id)
        out.write("Registered %s as a new action provider.\n" % tool_id)

    return out.getvalue()
コード例 #43
0
ファイル: utils.py プロジェクト: a25kk/stv2
def setupSkins(self, out, globals, skin_selections, select_skin, default_skin,
                          allow_any, cookie_persistence, skins_dir='skins'):
    skins_tool = getToolByName(self, 'portal_skins')

    # Add directory views
    addDirectoryViews(skins_tool, skins_dir, globals)
    print >> out, "Added directory views to portal_skins."

    # Install skin selections
    for skin in skin_selections:
        make_default = False
        if select_skin and skin['name'] == default_skin:
            make_default = True
        setupSkin(self, out, globals, skin, make_default,
                                   allow_any, cookie_persistence, skins_dir)
コード例 #44
0
    def setupSAPLSkins(self, p):
        sk_tool = getToolByName(p, 'portal_skins')

        # pega a definicao da skin layer basica do cmf
        path=[elem.strip() for elem in sk_tool.getSkinPath('Basic').split(',')]

        # retira as layers padroes do cmf
        existing_layers=sk_tool.objectIds()
        cmfdefault_layers=('zpt_topic', 'zpt_content', 'zpt_generic',
                           'zpt_control', 'topic', 'content', 'generic',
                           'control', 'Images', 'no_css', 'nouvelle')
        for layer in cmfdefault_layers:
            # tenha certeza que ira remover apenas se a layer nao existir
            # ou se ela eh um Filesystem Directory View
            # para prevenir a exclusao de custom layers
            remove = 0
            l_ob = getattr(sk_tool, layer, None)
            if not l_ob or getattr(l_ob, 'meta_type', None) == \
                   'Filesystem Directory View':
                remove = 1
            # remove da definicao de layer
            if layer in path and remove: path.remove(layer)
            # remove da skin tool
            if layer in existing_layers and remove:
                sk_tool.manage_delObjects(ids=[layer])

        # adiciona a layer do Openlegis
        sapldir = 'sk_sapl'
        if sapldir not in path:
            try:
                path.insert( path.index( 'custom')+1, sapldir )
            except ValueError:
                path.append( sapldir )

        path=','.join(path)
        sk_tool.addSkinSelection('SAPL', path, make_default=1)

        addDirectoryViews( sk_tool, 'skins', GLOBALS )

        skins_map=sk_tool._getSelections()

        if skins_map.has_key('No CSS'):
            del skins_map['No CSS']
        if skins_map.has_key('Nouvelle'):
            del skins_map['Nouvelle']
        if skins_map.has_key('Basic'):
            del skins_map['Basic']
        sk_tool.selections=skins_map
コード例 #45
0
 def setUp(self):
     FSDVTest.setUp(self)
     self.app = makerequest(Zope.app())
     self._registerDirectory()
     ob = self.ob = self.app
     addDirectoryViews(ob, self._skinname, self.tempname)
     self.r = self.app.REQUEST
     self.r.other['URL1'] = 'http://foo/test_mt'
     self._add= self.app.manage_addProduct['MailTemplates'].addMailTemplate
     self.folder = Folder('folder')
     if getattr(self.app,'test_mt',None):
         self.app.manage_delObjects(ids=['test_mt'])
     if getattr(self.app,'MailHost',None):
         self.app.manage_delObjects(ids=['MailHost'])
     self.MailHost = self.app.MailHost = DummyMailHost()
     newSecurityManager( None, SystemUser )
コード例 #46
0
def install_subskin(self, out, skin_name, globals=cmfepoz_globals):
    skinstool=getToolByName(self, 'portal_skins')
    if skin_name not in skinstool.objectIds():
        addDirectoryViews(skinstool, 'epoz', globals)

    for skinName in skinstool.getSkinSelections():
        path = skinstool.getSkinPath(skinName)
        path = [i.strip() for i in  path.split(',')]
        try:
            if skin_name not in path:
                path.insert(path.index('custom') +1, skin_name)
        except ValueError:
            if skin_name not in path:
                path.append(skin_name)

        path = ','.join(path)
        skinstool.addSkinSelection(skinName, path)
コード例 #47
0
def install(self):
    out = StringIO()

    skins_tool = getToolByName(self, 'portal_skins')

    # Setup the skins
    if key  not in skins_tool.objectIds():
        addDirectoryViews(skins_tool, 'skins',  textindexng_globals)
        out.write("Added %s skin directory view to portal_skins\n" % key)

    # Now we need to go through the skin configurations and insert
    # 'textindexng' into the configurations.  Preferably, this should be
    # right before where 'content' is placed.  Otherwise, we append
    # it to the end.
    skins = skins_tool.getSkinSelections()

    for skin in skins:
        path = skins_tool.getSkinPath(skin)
        path = [p.strip() for p in  path.split(',')]

        if key not in path:
            try: path.insert(0, key)
            except ValueError:
                path.append(key)

            path = ', '.join(path)
            # addSkinSelection will replace exissting skins as well.
            skins_tool.addSkinSelection(skin, path)
            out.write("Added '%s' to %s skin\n" % (key, skin))
        else:
            out.write("Skipping %s skin, '%s' is already set up\n" % (
                key, skin))


    configTool = getToolByName(self, 'portal_controlpanel', None)
    if configTool:
        for conf in configlets:
            print('Adding configlet %s\n' % conf['id'], file=out)
            try: # Plone 4.x
                configTool.registerConfiglet(**conf)
            except TypeError: # Plone 5
                del conf['imageUrl']
                configTool.registerConfiglet(**conf)

    print("Successfully installed", file=out)  
    return out.getvalue()
コード例 #48
0
    def test_fsmetadata_from_egg(self):
        from pkg_resources import require
        from Products.CMFCore.DirectoryView import addDirectoryViews
        from Products.CMFCore.DirectoryView import registerDirectory

        faux_globals = {'__name__': 'Products.Rotten'}
        require('rotten')
        registerDirectory('skins', faux_globals)

        ob = DummyFolder()
        self.failIf('rotten' in ob.__dict__)
        addDirectoryViews(ob, 'skins', faux_globals)
        self.failUnless('rotten' in ob.__dict__)

        rotten = ob.rotten
        template = rotten._getOb('rotten')
        self.assertEqual(template.title, 'Rotten Template')
コード例 #49
0
ファイル: utils.py プロジェクト: dipp/Products.DiPP
def setupSkins(self,
               out,
               globals,
               skin_selections,
               select_skin,
               default_skin,
               allow_any,
               cookie_persistence,
               skins_dir='skins'):
    addDirectoryViews(getToolByName(self, 'portal_skins'), skins_dir, globals)
    print >> out, "Added directory views to portal_skins."

    for skin in skin_selections:
        make_default = False
        if select_skin and skin['name'] == default_skin:
            make_default = True
        setupSkin(self, out, globals, skin, make_default, allow_any,
                  cookie_persistence, skins_dir)
コード例 #50
0
def customizeSkins(self, portal):
    st = getToolByName(portal, 'portal_skins')

    # We need to add Filesystem Directory Views for any directories in
    # our skins/ directory.  These directories should already be
    # configured.
    addDirectoryViews(st, 'skins', product_globals)

    # FIXME: we need a better way of constructing this
    pathlist= [p.strip() for p in st.getSkinPath('Plone Default').split(',')]
    pathlist.insert(1, 'rhaptos_site')
    pathlist.insert(1, 'rhaptos_overrides')
    path = ','.join(pathlist)

    # Create a new 'Rhaptos' skin
    st.addSkinSelection('Rhaptos', path, make_default=1)

    # disallow changing of skins (skin flexibility)
    st.allow_any = 0
コード例 #51
0
def installSkins(portal, skins_abspath, GLOBALS):
    skins_tool = getToolByName(portal, 'portal_skins')
    addDirectoryViews(skins_tool, 'skins', GLOBALS)

    skins = skins_tool.getSkinSelections()
    for skin in skins:
        path = skins_tool.getSkinPath(skin)
        #split up the skin path and  insert the current one just after custom if its not already in there
        path = [s.strip() for s in path.split(',') if s]
        skins_to_add = getSkins(skins_abspath)
        skins_to_add.reverse()
        for n in skins_to_add:
            if n not in path:
                try:
                    path.insert(path.index('custom') + 1, n)
                except ValueError:
                    path.append(n)
        path = ','.join(path)
        # addSkinSelection will replace existing skins as well.
        skins_tool.addSkinSelection(skin, path)
コード例 #52
0
def customizeSkins(self, portal):
    skinstool = getToolByName(portal, 'portal_skins')

    # We need to add Filesystem Directory Views for any directories
    # in our skins/ directory.  These directories should already be
    # configured.
    addDirectoryViews(skinstool, 'skins', product_globals)
    zLOG.LOG("CNXSitePolicy", zLOG.INFO,
             "Added 'CNXPloneSite' directory view to portal_skins")

    # FIXME: we need a better way of constructing this
    pathlist = [p.strip() for p in skinstool.getSkinPath('Rhaptos').split(',')]
    pathlist.insert(1, 'CNXPloneSite')
    pathlist.insert(1, 'cnx_overrides')
    path = ','.join(pathlist)

    # Create a new 'Connexions' skin
    skinstool.addSkinSelection('Connexions', path, make_default=1)
    zLOG.LOG("CNXSitePolicy", zLOG.INFO,
             "Added 'Connexions' as new default skin")
コード例 #53
0
def install_subskin(self, out, skin_name=SKIN_NAME, globals=groupuserfolder_globals):
    print >>out, "  Installing subskin."
    skinstool=getToolByName(self, 'portal_skins')
    if skin_name not in skinstool.objectIds():
        print >>out, "    Adding directory view for GRUF"
        addDirectoryViews(skinstool, 'skins', globals)

    for skinName in skinstool.getSkinSelections():
        path = skinstool.getSkinPath(skinName)
        path = [i.strip() for i in  path.split(',')]
        try:
            if skin_name not in path:
                path.insert(path.index('custom') +1, skin_name)
        except ValueError:
            if skin_name not in path:
                path.append(skin_name)

        path = ','.join(path)
        skinstool.addSkinSelection( skinName, path)
    print >>out, "  Done installing subskin."
コード例 #54
0
        def setUp(self):

            # initialise skins
            registerDirectory('fake_skins', _prefix)
            ob = self.ob = DummyFolder()
            addDirectoryViews(ob, 'fake_skins', _prefix)

            # add a method to the fake skin folder
            f = open(test2path, 'w')
            f.write("return 'test2'")
            f.close()

            # edit the test1 method
            copy2(test1path, test1path + '.bak')
            f = open(test1path, 'w')
            f.write("return 'new test1'")
            f.close()

            # add a new folder
            mkdir(test3path)
コード例 #55
0
ファイル: Install.py プロジェクト: bendavis78/zope
def install(self):
    " Register the CMF Topic with portal_types and friends "
    out = StringIO()
    typestool = getToolByName(self, 'portal_types')
    skinstool = getToolByName(self, 'portal_skins')

    # Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
    for t in Topic.factory_type_information:
        if t['id'] not in typestool.objectIds():
            cfm = apply(ContentFactoryMetadata, (), t)
            typestool._setObject(t['id'], cfm)
            out.write('Registered with the types tool\n')
        else:
            out.write('Object "%s" already existed in the types tool\n' %
                      (t['id']))

    # Setup the skins
    # This is borrowed from CMFDefault/scripts/addImagesToSkinPaths.pys
    if 'topic' not in skinstool.objectIds():
        addDirectoryViews(skinstool, 'skins', topic_globals)
        out.write("Added 'topic' directory view to portal_skins\n")
    skins = skinstool.getSkinSelections()
    for skin in skins:
        path = skinstool.getSkinPath(skin)
        path = map(string.strip, string.split(path, ','))
        if 'topic' not in path:
            try:
                path.insert(path.index('content'), 'topic')
            except ValueError:
                path.append('topic')

            path = string.join(path, ', ')
            # addSkinSelection will replace exissting skins as well.
            skinstool.addSkinSelection(skin, path)
            out.write("Added 'topic' to %s skin\n" % skin)
        else:
            out.write("Skipping %s skin, 'topic' is already set up\n" % (skin))

    return out.getvalue()
コード例 #56
0
ファイル: Install.py プロジェクト: redragonvn/misc
def setupSkin(self, out):

    skinsTool = getToolByName(self, 'portal_skins')

    # Add directory views
    try:
        addDirectoryViews(skinsTool, 'skins', GLOBALS)
        #install_subskin(self, out, GLOBALS)
        out.write("Added directory views to portal_skins.\n")
    except:
        out.write('*** Unable to add directory views to portal_skins.\n')

    for skin_name in SKIN_NAMES:
        path = skinsTool.getSkinPath(BASE_SKIN)
        path = map(string.strip, string.split(path, ','))

        # add lib folder
        for lib_folder in LIB_FOLDERS:
            if lib_folder not in path:
                try:
                    path.insert(path.index('custom') + 1, lib_folder)
                except:
                    path.append(lib_folder)

        # add skin folders to this path, under 'custom'
        try:
            path.insert(path.index('custom') + 1, skin_name)
            path = string.join(path, ', ')
            skinsTool.addSkinSelection(skin_name, path)
        except:
            out.write('adding skin %s failed' % skin_name)

    # change default skin
    try:
        skinsTool.manage_properties(default_skin=DEFAULT_SKIN)
        out.write('switched default skin to %s \n' % DEFAULT_SKIN)
    except:
        out.write('failed to set default_skin to %s \n' % DEFAULT_SKIN)