[Zope-CMF] what method is called first when a CMF Site is viewed ?
Ausum Studio
ausum_studio@hotmail.com
Tue, 15 Apr 2003 08:37:04 -0500
You create a product folder and name it as the last possible one that will
load, something like "ZZOnSiteStart", place there the __init__ calling the
checking method inside your target CMF site, and you're done.
Ausum
----- Original Message -----
From: "robert" <robert@redcor.ch>
To: <r.ritz@biologie.hu-berlin.de>; "Raphael Ritz"
<ritz@itb.biologie.hu-berlin.de>
Cc: "Ausum Studio" <ausum_studio@hotmail.com>; <zope-cmf@zope.org>
Sent: Tuesday, April 15, 2003 3:56 AM
Subject: Re: [Zope-CMF] what method is called first when a CMF Site is
viewed ?
Hi Raphael,
thanks for your answer.
I see I have to explain why I can not do it the "right way".
I have a "intranet construction kit" which construct an intranet from a
excelsheet (where structure, rigths, workflows etc are defined) and a set of
definition files where all the rest of zillion plone/cmf settings are
defined.
These definition files are stored together with all skin files for this
particular intanet somewhere in a data directory on the filesystem. This
directory is NOT part of any product.
New Plone sites are constructed by help of a CustomizationPolicy that locate
the data directory by help of the new sites title.
While constructing the site the CMF's skin search is temporarily patched to
find the skins in the data directory.
This all works very well and is extremly flexible.
Some times however (and I have not discovered why yet) a site "looses" all
content of the "special" skins when restarting zope. I have to manually call
the setup routine from the construction kit to fix up the skins.
So what I want to do at startup is checking whether the skins are there, and
call this routine if not.
Obviously this has to be done before anything tries to access them.
What I need is a hook, an __init__ or what ever that where I can add a call
to
the routine mentined.
thanks again
Robert
Am Dienstag, 15. April 2003 10:31 schrieb Raphael Ritz:
> 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
--
mit freundlichen Grüssen
Robert Rottermann
www.redCOR.ch