Back to index

plone3  3.1.7
Classes | Functions | Variables
Install Namespace Reference

Classes

class  PloneSkinRegistrar

Functions

def install
def uninstall
def uninstall
def install_plone
def _read_resources
def css_files
def js_files
def install_resources
def uninstall_resources
def install_libraries
def install_configlet
def install_transform
def install_customisation
def uninstall_transform
def uninstall_tool

Variables

string __version__ = "$Revision: 61118 $"
 CMFPlacefulWorkflow Copyright (C)2005 Ingeniweb.
string __docformat__ = 'restructuredtext'
tuple kupu_package_dir = package_home(kupu_globals)

Function Documentation

def Install._read_resources ( ) [private]

Definition at line 64 of file Install.py.

00064 
00065 def _read_resources():
00066     resourcefile = open(os.path.join(kupu_package_dir, 'plone', 'head.kupu'), 'r')
00067     try:
00068         data = resourcefile.read()
00069         return data
00070     finally:
00071         resourcefile.close()

Here is the caller graph for this function:

def Install.css_files (   resources)

Definition at line 72 of file Install.py.

00072 
00073 def css_files(resources):
00074     CSSPAT = re.compile(r'<link [^>]*rel="stylesheet"[^>]*\${portal_url}/([^"]*)"')
00075     for m in CSSPAT.finditer(resources):
00076         id = m.group(1)
00077         yield id

Here is the caller graph for this function:

def Install.install ( )
Register password reset skins and add the tool

Definition at line 7 of file Install.py.

00007 
00008 def install(self):
00009     out = StringIO()
00010     
00011     # remove comments if you whish to install the demo type
00012     # installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME)
00013     
00014     # install property for startup_directory
00015     props = getToolByName(self, "portal_properties").site_properties
00016     if not props.hasProperty('refwidget_startupdirectories'):
00017         props._setProperty('refwidget_startupdirectories', [], 'lines')
00018         out.write('Registered property refwidget_startupdirectories in site_properties - see readme.txt')
00019 
00020     install_subskin(self, out, GLOBALS)
00021     out.write("Successfully installed %s." % PROJECTNAME)
00022     return out.getvalue()

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.install_configlet (   self,
  out 
)

Definition at line 178 of file Install.py.

00178 
00179 def install_configlet(self, out):
00180     try:
00181         portal_conf=getToolByName(self,'portal_controlpanel')
00182     except AttributeError:
00183         print >>out, "Configlet could not be installed"
00184         return
00185     try:
00186         portal_conf.registerConfiglet( 'kupu'
00187                , TOOLTITLE
00188                , 'string:${portal_url}/%s/kupu_config' % TOOLNAME
00189                , ''                 # a condition   
00190                , 'Manage portal'    # access permission
00191                , 'Plone'            # category to which kupu should be added: 
00192                                     # (Plone,Products,Members) 
00193                , 1                  # visibility
00194                , PROJECTNAME
00195                , 'kupuimages/kupu_icon.gif' # icon in control_panel
00196                , 'Kupu Library Tool'
00197                , None
00198                )
00199     except KeyError:
00200         pass # Get KeyError when registering duplicate configlet.

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.install_customisation (   self,
  out 
)
Default settings may be stored in a customisation policy script so
that the entire setup may be 'productised'

Definition at line 208 of file Install.py.

00208 
00209 def install_customisation(self, out):
00210     """Default settings may be stored in a customisation policy script so
00211     that the entire setup may be 'productised'"""
00212 
00213     # Skins are cached during the request so (in case new skin
00214     # folders have just been added) we need to force a refresh of the
00215     # skin.
00216     self.changeSkin(None)
00217 
00218     scriptname = '%s-customisation-policy' % PROJECTNAME.lower()
00219     cpscript = getattr(self, scriptname, None)
00220     # If the user hasn't created a CP then use the sample.
00221     if not cpscript:
00222         cpscript = getattr(self, 'sample-kupu-customisation-policy', None)
00223     if cpscript:
00224         cpscript = cpscript.__of__(self)
00225 
00226     if cpscript:
00227         print >>out,"Customising %s" % PROJECTNAME
00228         print >>out,cpscript()
00229     else:
00230         print >>out,"No customisation policy"

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.install_libraries (   self,
  out 
)
Install everything necessary to support Kupu Libraries

Definition at line 159 of file Install.py.

00159 
00160 def install_libraries(self, out):
00161     """Install everything necessary to support Kupu Libraries
00162     """
00163     # add the library tool
00164     addTool = self.manage_addProduct['kupu'].manage_addTool
00165     try:
00166         addTool('Kupu Library Tool')
00167         print >>out, "Added the Kupu Library Tool to the plone Site"
00168     except BadRequest:
00169         print >>out, "Kupu library Tool already added"    
00170     except: # Older Zopes
00171         #heuristics for testing if an instance with the same name already exists
00172         #only this error will be swallowed.
00173         #Zope raises in an unelegant manner a 'Bad Request' error
00174         e=sys.exc_info()
00175         if e[0] != 'Bad Request':
00176             raise
00177         print >>out, "Kupu library Tool already added"    

Here is the caller graph for this function:

def Install.install_plone (   self,
  out 
)
Install with plone

Definition at line 39 of file Install.py.

00039 
00040 def install_plone(self, out):
00041     """Install with plone
00042     """
00043     # register the plone skin layers
00044     register_layer(self, 'plone/kupu_plone_layer', 'kupu_plone', out)
00045     # By default, add the directory view but not the skin layer for the reference browser
00046     register_layer(self, 'plone/kupu_references', 'kupu_references', out, add=False)
00047     register_layer(self, 'tests', 'kupu_tests', out)
00048 
00049     # register as editor
00050     portal_props = getToolByName(self, 'portal_properties')
00051     site_props = getattr(portal_props,'site_properties', None)
00052     attrname = 'available_editors'
00053     if site_props is not None:
00054         editors = list(site_props.getProperty(attrname)) 
00055         if 'Kupu' not in editors:
00056             editors.append('Kupu')
00057             site_props._updateProperty(attrname, editors)        
00058             print >>out, "Added 'Kupu' to available editors in Plone."
00059     install_libraries(self, out)
00060     install_configlet(self, out)
00061     install_transform(self, out)
00062     install_resources(self, out)
00063     install_customisation(self, out)

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.install_resources (   self,
  out 
)
Add the js and css files to the resource registry so that
they can be merged for download.

Definition at line 86 of file Install.py.

00086 
00087 def install_resources(self, out):
00088     """Add the js and css files to the resource registry so that
00089     they can be merged for download.
00090     """
00091     try:
00092         from Products.ResourceRegistries.config import CSSTOOLNAME, JSTOOLNAME
00093     except ImportError:
00094         print >>out, "Resource registry not found: kupu will load its own resources"
00095         return
00096 
00097     data = _read_resources()
00098     
00099     CONDITION = '''python:portal.kupu_library_tool.isKupuEnabled(REQUEST=request)'''
00100     csstool = getToolByName(self, CSSTOOLNAME, None)
00101     jstool = getToolByName(self, JSTOOLNAME, None)
00102     if csstool is None or jstool is None:
00103         return
00104 
00105     for id in css_files(data):
00106         print >>out, "CSS file", id
00107         cookable = True
00108         csstool.manage_removeStylesheet(id=id)
00109         csstool.manage_addStylesheet(id=id,
00110             expression=CONDITION,
00111             rel='stylesheet',
00112             enabled=True,
00113             cookable=cookable)
00114 
00115     existing = [ sheet.getId() for sheet in jstool.getResources()]
00116     if 'kupucontextmenu.js' in existing:
00117         jstool.manage_removeScript('kupucontextmenu.js');
00118     # Insert sarissa.js into the scripts but only if it isn't already
00119     # there.
00120     SARISSA = 'sarissa.js'
00121     if SARISSA not in existing:
00122         jstool.manage_addScript(id=SARISSA, enabled=True,
00123             cookable=True,
00124             compression='safe',
00125             cacheable=True)
00126         if 'plone_javascripts.js' in existing:
00127             jstool.moveResourceAfter(SARISSA, 'plone_javascripts.js')
00128         else:
00129             jstool.moveResourceToBottom(SARISSA)
00130         print >>out, "JS file", SARISSA
00131 
00132     for id in js_files(data):
00133         print >>out, "JS file", id
00134         jstool.manage_removeScript(id=id)
00135         jstool.manage_addScript(id=id,
00136             expression=CONDITION,
00137             enabled=True,
00138             compression='safe',
00139             cookable=True)

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.install_transform (   self,
  out 
)

Definition at line 201 of file Install.py.

00201 
00202 def install_transform(self, out):
00203     try:
00204         util.install_transform(self)
00205         util.remove_transform(self) # Transform is installed but disabled by default.
00206     except (NameError,AttributeError):
00207         print >>out, "Transform not installed."

Here is the caller graph for this function:

def Install.js_files (   resources)

Definition at line 78 of file Install.py.

00078 
00079 def js_files(resources):
00080     JSPAT = re.compile(r'<script [^>]*\${portal_url}/([^"]*)"')
00081     for m in JSPAT.finditer(resources):
00082         id = m.group(1)
00083         if id=='sarissa.js':
00084             continue
00085         yield id

Here is the caller graph for this function:

def Install.uninstall (   self,
  reinstall = False,
  out = None 
)

Definition at line 38 of file Install.py.

00038 
00039 def uninstall(self, reinstall=False, out=None):
00040     if out is None:
00041         out = StringIO()
00042 
00043     getSiteManager(self).unregisterUtility(self['portal_placeful_workflow'],
00044                                            IPlacefulWorkflowTool)
00045     # uninstall configlets
00046     try:
00047         cptool = getToolByName(self, 'portal_controlpanel')
00048         cptool.unregisterConfiglet(placeful_prefs_configlet['id'])
00049         out.write('Removing CMFPlacefulWorkflow Configlet')
00050     except:
00051         out.write('Failed to remove CMFPlacefulWorkflow Configlet')
00052 
00053     wf_tool = getToolByName(self, 'portal_workflow')
00054     if IPlacefulMarker.providedBy(wf_tool):
00055         noLongerProvides(wf_tool, IPlacefulMarker)
00056 
00057     return out.getvalue()

Here is the call graph for this function:

def Install.uninstall (   self)

Definition at line 154 of file Install.py.

00154 
00155 def uninstall(self):
00156     out = StringIO()
00157     classes=listTypes(PROJECTNAME)
00158 
00159     #unregister folderish classes in use_folder_contents
00160     props=getToolByName(self,'portal_properties').site_properties
00161     use_folder_tabs=list(props.use_folder_tabs)
00162     print >> out, 'removing classes from use_folder_tabs:'
00163     for cl in classes:
00164         print >> out,  'type:', cl['klass'].portal_type
00165         if cl['klass'].isPrincipiaFolderish and not cl['klass'].portal_type in []:
00166             if cl['klass'].portal_type in use_folder_tabs:
00167                 use_folder_tabs.remove(cl['klass'].portal_type)
00168 
00169     props.use_folder_tabs=tuple(use_folder_tabs)
00170 
00171     return out.getvalue()

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.uninstall_resources (   self,
  out 
)
Remove the js and css files from the resource registries

Definition at line 140 of file Install.py.

00140 
00141 def uninstall_resources(self, out):
00142     """Remove the js and css files from the resource registries"""
00143     try:
00144         from Products.ResourceRegistries.config import CSSTOOLNAME, JSTOOLNAME
00145     except ImportError:
00146         return
00147 
00148     data = _read_resources()
00149     
00150     csstool = getToolByName(self, CSSTOOLNAME)
00151     jstool = getToolByName(self, JSTOOLNAME)
00152 
00153     for id in css_files(data):
00154         csstool.manage_removeStylesheet(id=id)
00155 
00156     for id in js_files(data):
00157         jstool.manage_removeScript(id=id)
00158     print >>out, "Resource files removed"
    

Here is the call graph for this function:

Here is the caller graph for this function:

def Install.uninstall_tool (   self,
  out 
)

Definition at line 259 of file Install.py.

00259 
00260 def uninstall_tool(self, out):
00261     try:
00262         self.manage_delObjects([TOOLNAME])
00263     except:
00264         pass
00265     else:
00266         print >>out, "Kupu tool removed"

Here is the call graph for this function:

def Install.uninstall_transform (   self,
  out 
)

Definition at line 248 of file Install.py.

00248 
00249 def uninstall_transform(self, out):
00250     transform_tool = getToolByName(self, 'portal_transforms')
00251     try:
00252         util.remove_transform(self)
00253         transform_tool.manage_delObjects(['html-to-captioned', 'captioned-to-html'])
00254     except:
00255         print >>out, "Transform not removed"
00256         pass
00257     else:
00258         print >>out, "Transform removed"

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

string Install.__docformat__ = 'restructuredtext'

Definition at line 24 of file Install.py.

string Install.__version__ = "$Revision: 61118 $"

CMFPlacefulWorkflow Copyright (C)2005 Ingeniweb.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Definition at line 21 of file Install.py.

tuple Install.kupu_package_dir = package_home(kupu_globals)

Definition at line 37 of file Install.py.