GoZip/Extensions Install.py,1.1.1.1,1.2
Jens Klein <[email protected]>
| Newsgroups | gmane.comp.web.zope.eduplone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/eduplone/GoZip/Extensions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27759/Extensions
Modified Files:
Install.py
Log Message:
better install, use ATCT, docu updated, extensions handling improved.
Index: Install.py
===================================================================
RCS file: /cvsroot/eduplone/GoZip/Extensions/Install.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Install.py 16 Dec 2003 01:05:02 -0000 1.1.1.1
--- Install.py 13 Jun 2004 13:34:35 -0000 1.2
***************
*** 1,132 ****
from Products.CMFCore.utils import getToolByName
- from Products.CMFCore.DirectoryView import addDirectoryViews
from Products.ExternalMethod.ExternalMethod import ExternalMethod
!
!
! from Products.Archetypes.Extensions.utils import installTypes
! from Products.Archetypes import listTypes
! from Products.GoZip import PROJECTNAME,product_globals
!
from StringIO import StringIO
! class PloneSkinRegistrar:
! """
! Controls (un)registering of a layer in the skins tool:
! - the layer in the content of the skin tool
! - the layer in the path of all skins
! @author: U{Gilles Lenfant <[email protected]>}
! @version: 0.1.0
! @ivar _layer: Name of the Product's subdirectory that contains
! the various layers for the Product.
! @type _layer: string
! @ivar _prodglobals: Globals from this Product.
! @type _propglobals: mapping object
! """
!
! def __init__(self, skinsdir, prodglobals):
! """Constructor
! @param skinsdir: Name of the Product's subdirectory that
! contains the various layers for the Product.
! @type skinsdir: string
! @param prodglobals: Globals from this Product.
!
! should be provided by Product's C{__init__.py} like this:
!
! C{product_globals = globals()}
!
! @type propglobals: mapping object
! @return: None
! """
!
! self._skinsdir = skinsdir
! self._prodglobals = prodglobals
! return
!
! def install(self, aq_obj):
! """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
!
! 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
!
! # 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)
!
! 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:
! layers.insert(layers.index('content'), layerName)
! except ValueError:
! layers.append(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
!
! def uninstall(self, aq_obj):
! """Uninstalls and unregisters the skin resources
! @param aq_obj: object from which cmf site object is acquired
! @type aq_obj: any Zope object in the CMF
! @return: Uninstallation log
! @rtype: string
! """
!
! rpt = '=> Uninstalling and unregistering %s layer\n' % self._skinsdir
! skinstool = getToolByName(aq_obj, 'portal_skins')
!
! # Removing layer from portal_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)
!
! layerName = self._prodglobals['__name__'].split('.')[-1]
! if layerName in skinstool.objectIds():
! skinstool.manage_delObjects([layerName])
! rpt += 'Removed "%s" directory view from portal_skins\n' % layerName
! else:
! rpt += '! Warning: directory view "%s" already removed from portal_skins\n' % layerName
!
! # Removing from skins selection
!
! skins = skinstool.getSkinSelections()
! for skin in skins:
! layers = skinstool.getSkinPath(skin)
! layers = [layer.strip() for layer in layers.split(',')]
! if layerName in layers:
! layers.remove(layerName)
! layers = ','.join(layers)
! skinstool.addSkinSelection(skin, layers)
! rpt += 'Removed "%s" to "%s" skin\n' % (layerName, skin)
! else:
! rpt += 'Skipping "%s" skin, "%s" is already removed\n' % (skin, layerName)
! return rpt
! # /class PloneSkinRegistrar
def install(self):
!
! # install dependencies
! ##qi=getToolByName(self, 'portal_quickinstaller')
! ##if not qi.isProductInstalled('Archetypes'):
! ## qi.installProduct('Archetypes')
out = StringIO()
classes=listTypes(PROJECTNAME)
installTypes(self, out,
--- 1,15 ----
from Products.CMFCore.utils import getToolByName
from Products.ExternalMethod.ExternalMethod import ExternalMethod
! from Products.Archetypes.public import listTypes
! from Products.Archetypes.Extensions.utils import installTypes, install_subskin
from StringIO import StringIO
! from Products.GoZip.config import *
def install(self):
! """ install this product """
out = StringIO()
+ install_dependencies(self, out)
classes=listTypes(PROJECTNAME)
installTypes(self, out,
***************
*** 135,140 ****
print >> out, "Successfully installed %s." % PROJECTNAME
! sr = PloneSkinRegistrar('skins', product_globals)
! print >> out,sr.install(self)
#register folderish classes in use_folder_contents
--- 18,22 ----
print >> out, "Successfully installed %s." % PROJECTNAME
! install_subskin(self, out, GLOBALS)
#register folderish classes in use_folder_contents
***************
*** 161,168 ****
if res:
print >>out,res
- else:
- print >>out,'no output'
- else:
- print >>out,'no custom install'
return out.getvalue()
--- 43,46 ----
***************
*** 186,188 ****
--- 64,71 ----
return out.getvalue()
+ def install_dependencies(self, out):
+ deps = ['Archetypes','ATContentTypes']
+ print >> out, '%s depends on %s, try to auto-install.' % (PROJECTNAME,','.join(deps))
+ qi = getToolByName(self,'portal_quickinstaller')
+ qi.installProducts(deps, stoponerror=1)
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504