[Zope-CMF] what method is called first when a CMF Site is viewed ?

Raphael Ritz r.ritz@biologie.hu-berlin.de
15 Apr 2003 10:31:34 +0200


Am Mon, 2003-04-14 um 19.22 schrieb robert:
> Ausum
> thank you very  much for your answer.
> What I need is a method that sets up a "non standard" skins path that should 
> be called once when plone/cmf  starts up.
> Since it fiddles with the skins path It can not be  in one of "my" skins, they 
> will be found only after the method has been executed.
> In fact the method needs to be run only once after zope has started up but 
> everytimes a site is started is fine.

Not sure I understand your problem but why don't you do it 
the way skins are usually set up (from within a file system 
based product).

First in __init__.py you register your skin directories
e.g., like (examples taken from my Bibliography product)
...
registerDirectory('cmf_skins', globals())
registerDirectory('cmf_skins/bibliography', globals())
registerDirectory('plone_skins', globals())
registerDirectory('plone_skins/bibliography', globals())
...

then in Extensions/Install.py you do
...


def installSubSkin(self, out, skinFolder):
    """ Install a subskin, i.e. a folder/directoryview.
    """
    skinsTool = getToolByName(self, 'portal_skins')

    for skin in skinsTool.getSkinSelections():
        path = skinsTool.getSkinPath(skin)
        path = map( string.strip, string.split( path,',' ) )
        if not skinFolder in path:
            try:
                path.insert( path.index( 'custom')+1, skinFolder )
            except ValueError:
                path.append(skinFolder)
            path = string.join( path, ', ' )
            skinsTool.addSkinSelection( skin, path )
            out.write('Subskin successfully installed into %s.\n' %
skin)
        else:
            out.write('*** Subskin was already installed into %s.\n' %
skin)


def setupTypesandSkins(self, out, isPlone):
    typesTool = getToolByName(self, 'portal_types')
    skinsTool = getToolByName(self, 'portal_skins')

    # Former types deletion (added by PJG)
    ...

    # Install de chaque nouvelle subskin/layer

    # are we in a Plone site?
    if isPlone:
        skin_folder = "plone_skins"
    else:
        skin_folder = "cmf_skins"

    try:
        addDirectoryViews(skinsTool, skin_folder, install_globals)
        out.write( "Added directory views to portal_skins.\n" )
    except:
        out.write( '*** Unable to add directory views to
portal_skins.\n')

    # Param de chaque nouvelle subskin/layer
    installSubSkin(self, out, skin_name)
...

Look how the skin path is manipulated within the 'installSubSkin'
call. You should be able to do similar things also on the fly
(meaning from methods called when first viewed or whatever).

HTH

	Raphael